SlideShare une entreprise Scribd logo
1  sur  72
WEB TECHNOLOGY
CASCADING STYLE SHEET
ADVANCED
DR. JYOTI YADAV
CSS NOT (NEGATION) PSEUDO CLASS
Syntax of not pseudo class selector:
selector : not(argument)
{
declaration list;
}
It selects any html element targeted by the selector, if it does not match the argument passed to not
pseudo class.
Ex:
p : not(.first)
{
border : 2px dotted blue;
}
It selects any p element, if it has no class attribute value set to first.
Ex:
input : not(:disabled)
{
border : 2px dotted blue;
}
It selects any input element,if it is not disabled
CSS – PSEUDO ELEMENTS
Ex:
p::before
{
content : ”Hello “;
}
It generates the specified content (i.e. Hello) before the content of any p element.
Ex:
p::after
{
content : ” HTML!“;
}
It generates the specified content (i.e. HTML!) after the content of any p element.
CSS SPECIFICITY RULES
What happens when we define set of style rules for a specific tag in external, internal
as well as inline styles?
The answer is:“rules get’s cascade”
The rules of the cascade include:
More specific selector’s properties override less specific selector’s
properties.
Nearest properties override farthest properties, when specificity is
equivalent.
Finally for every tag a virtual declaration list is created by combining all
properties from all selectors
CSS UNIVERSAL SELECTOR(*)
It is used to target any html element on page and apply styles on it.
Syntax of universal Selector:
*
{
declaration list;
}
It targets to any html element on the page
Ex:
*
{
border:2px solid red;
}
It selects every html element on the page and applies 2px solid red border
*.firsttwo
{
border:2px solid red;
}
It selects any html element which has class attribute value set to firsttwo
CSS UNIVERSAL SELECTOR(*)
*#container
{
border:2px solid red;
}
It selects any html element which has id attribute value set to container
* > p
{
border:2px solid red;
}
It selects any p element which is the direct child of any html element
CSS PROPERTIES
1. Font-weight Property: It used to specify the boldness of the font.
Values: lighter | normal | bold | bolder | 100 | 200 | 300 | 400 | 500 | 600 | 700 |
800 | 900
2. Font-style Property: It used to specify the style of the text to be displayed.
Values: normal | italic | oblique (more italic)
3. Text-decoration Property: It used to specify the line formatting of the text
to be displayed
Values: none | underline | line-through | overline
4. Content Property: It is used to generate content dynamically at run time.
Values:“string” | open-quote | close-quote | url(“filepath”) | none
CSS PROPERTIES
5. background-color property: It is used to specify the background color for any
html element
Values: color name | hex value | rgb(0-255,0-255,0-255) | rgba(0-255,0-255,0-255,0-1)
| transparent
6. font-size property: It is used to specify the size of the font
Values: xx-small | x-small | smaller | small | medium | large | larger | x-large | xx-large |
length (pt, px , em, %)
7. text-align property: It is used to align the text horizontally
Values: left | center | right | justify
7. CSS FONT-SIZE PROPERTY VS HTML FONT
TAG SIZE ATTRIBUTE
It is used to specify the size of the font to be applied
Values: xx-small | x-small | smaller | small | medium | large | larger |
x-large | xx-large | length | %
Note:16px = 1em (px to em Ex: 10px / 16px = 0.625em)
size=1 == font-size:x-small == font-size:10px == font-size:0.625em
size=2 == font-size:small == font-size:13px == font-size:0.8125em
size=3 == font-size:medium == font-size:16px == font-size:1.0em
size=4 == font-size:large == font-size:18px == font-size:1.125em
size=5 == font-size:x-large == font-size:24px == font-size:1.5em
size=6 == font-size:xx-large == font-size:32px == font-size:2.0em
size=7 == == font-size:48px == font-size:3.0em
8. CSS COLOR PROPERTY VS HTML FONT TAG
COLOR ATTRIBUTE
It is used to specify the text color to be applied
Values: color name | hex value | rgb(0-255,0-255,0-255) | rgba(0-255,0-
255,0-255,0-1) | transparent
color name = ex: red, green, blue etc.
hex color value = ex: #ff0000, #00ff00, #0000ff etc.
rdb() = ex: rgb(255,0,0), rgb(0,255,0), rgb(0,0,255) etc.
rgba() = ex: rgba(255,0,0,1), rgba(0,255,0,1), rgba(0,0,255,1) etc.
9. CSS FONT-FAMILY PROPERTY VS HTML
FONT TAG FACE ATTRIBUTE
It used to specify the font to be applied to the content of an
HTML element
Values: specific font name (i.e. font face), specific font family name,
generic font family name
Ex:
font-family :‘Arial Black’;
font-family :‘Arial Black’,Arial;
font-family :‘Arial Black’,Arial, sans-serif;
CSS FONT-FAMILY PROPERTY VS HTML FONT
TAG FACE ATTRIBUTE
10. text-indent property: It is used to specify the indentation of the first line in the
paragraph
Values: length
11. text-align property: It is used to specify the horizontal alignment of the text
Values: left | center | right | justify
12. text-align-last property: It is used to specify the horizontal alignment of the last
line in the paragraph
Values: left | center | right | justify
13. letter-spacing property: It is used to specify the space between the letters or
characters
Values: length
14. word-spacing property: It is used to specify the space between the words
Values: length
15. line-height property: It is used to specify the space above and below the text
Values: length
CSS FONT-FAMILY PROPERTY VS HTML FONT
TAG FACE ATTRIBUTE
16. text-transform property: It is used to specify the text case to be applied
Values: uppercase | lowercase | capitalize
17. font-variant property: It is used to specify the text case to be applied
Values: small-caps | normal
18. text-shadow property: It is used to apply shadow effect to the text of an html
element
Value: shadow-x-offset shadow-y-offset shadow-color-spread-amount shadow-color;
19. box-shadow property: It is used to apply shadow effect to the html element
(rectangle box area)
Value: shadow-x-offset shadow-y-offset shadow-color-spread-amount shadow-color;
CSS FONT-FAMILY PROPERTY VS HTML FONT
TAG FACE ATTRIBUTE
20. list-style-type property: It is used to specify the bullet symbol to be displayed in
front of list items of html ol or html ul.
Values: decimal | decimal-leading-zero | upper-alpha | lower-alpha | upper-roman | lower-
roman | none | disc | circle | square etc.
21. list-style-image property: It is used to specify the image to be used as a bullet
symbol
Value: url(‘image path’);
Note: image size should be 12 x 12
22. list-style-position property: It is used to specify the position of the bullet symbol
with respect to list item’s border area.
Values: outside | inside
CSS BOX MODEL
HTML box with its component areas:
CSS Content area:The amount of space required to display the content or the area
occupied by the content
It is determined by CSS width property and CSS height property
CSS Padding area:The distance between the content and the border.The empty space
or empty area around the content. It is determined by CSS padding property
CSS Border area: The area occupied by the border.The area around the padding
meant to display border. It is determined by CSS border property.
CSS Margin area:The area around the border.The empty space or empty area around
the border. It is determined by CSS margin property
CSS BOX MODEL
Calculating actual width and actual height of an HTML element:
HTML element's actual width: is the amount of space occupied by an
HTML element horizontally
Actual width of an HTML element = content width + left padding
+ right padding + left border + right border + left margin + right margin
HTML element's actual height: is the amount of space occupied by an
HTML element vertically
Actual height of an HTML element = content height + top padding
+ bottom padding + top border + bottom border + top margin +
bottom margin
CSS CONTENT AREA PROPERTIES
CSS width property: It is used to specify, width of content area
Values: auto | length | %
CSS height property: It is used to specify, height of content area
Values: auto | length | %
CSS overflow property: It is used to specify, how the overflowed content to be
displayed
Values: visible | hidden | scroll
CSS overflow-x property: It is used to specify, whether the horizontal scroll bar
to be visible or hidden
Values: visible | hidden
CSS overflow-y property: It is used to specify, whether the vertical scroll bar to
be visible or hidden
Values: visible | hidden
CSS PADDING AREA PROPERTIES
CSS padding-top property:
It is used to specify the amount of area to be cleared above the content area of an html element
Values: length | %
CSS padding-right property:
It is used to specify the amount of area to be cleared on the right hand side of the content area of an
html element
Values: length | %
CSS padding-bottom property:
It is used to specify the amount of area to be cleared below the content area of an html element
Values: length | %
CSS padding-left property:
It is used to specify the amount of area to be cleared on the left hand side of the content area of an
html element
Values: length | %
CSS padding short hand property:
It is used to specify the amount of area to be cleared around the content area of an html element
Values: space separated list values (1, 2, 3, and 4)
CSS PADDING AREA PROPERTIES
Ex:
padding: 10px;
indicates: padding-top:10px; padding-right:10px; padding-bottom:10px; padding-
left:10px;
Ex:
padding: 10px 20px;
indicates: padding-top:10px; padding-bottom:10px; padding-right:20px; padding-
left:20px;
Ex:
padding: 10px 20px 10px ;
indicates: padding-top:10px; padding-right:20px; padding-left:20px; padding-
bottom:10px;
Ex:
padding: 10px 10px 10px 10px ;
indicates: padding-top:10px; padding-right:10px; padding-bottom:10px; padding-
left:10px;
CSS BORDER AREA PROPERTIES
CSS border-top-width property: It is used to specify the thickness of the top border of an html
element
Values: length
CSS border-top-style property: It is used to specify the style of the top border of an html element
Values: solid | double | dotted | dashed | groove | inset | outset | none
v CSS border-top-color property:
It is used to specify the color of the top border of an html element
Values: color
CSS border-right-width property: It is used to specify the thickness of the right border of an html
element
Values: length
CSS border-right-style property: It is used to specify the style of the right border of an html element
Values: solid | double | dotted | dashed | groove | inset | outset | none
CSS border-right-color property: It is used to specify the color of the right border of an html element
Values: color | hex color value
CSS border-bottom-width property:It is used to specify the thickness of the bottom border of an
html element
Values: length
CSS BORDER AREA PROPERTIES
CSS border- bottom -style property: It is used to specify the style of the bottom border of an
html element
Values: solid | double | dotted | dashed | groove | inset | outset | none
CSS border- bottom -color property: It is used to specify the color of the bottom border of an
html element
Values: color | hex color value
CSS border-left-width property: It is used to specify the thickness of the left border of an html
element
Values: length
CSS border-left-style property: It is used to specify the style of the left border of an html
element
Values: solid | double | dotted | dashed | groove | inset | outset | none
CSS border-left-color property: It is used to specify the color of the left border of an html
element
Values: color | hex color value
CSS BORDER PROPERTIES
CSS border-top short hand property:
It is used to specify the top border thickness, style and color in a single line
Values: border-top-width border-top-style border-top-color;
CSS border-right short hand property:
It is used to specify the right border thickness, style and color in a single line
Values: border-right-width border-right-style border-right-color;
CSS border- bottom short hand property:
It is used to specify the bottom border thickness, style and color in a single line
Values: border- bottom -width border- bottom -style border- bottom -color;
CSS border-left short hand property:
It is used to specify the left border thickness, style and color in a single line
Values: border-left-width border-left-style border-left-color;
CSS BORDER PROPERTIES
CSS border-width property: It is used to specify the thickness of the border of an
html element
Values: Space separated list of values (1, 2, 3 and 4)
CSS border-style property: It is used to specify the style of the border of an html
element
Values: Space separated list of values (1, 2, 3 and 4)
CSS border-color property: It is used to specify the color of the border of an html
element
Values: Space separated list of values (1, 2, 3 and 4)
4: top, right, bottom, left
3: top, right & left, bottom
2: top & bottom, right & left
1: top & right & bottom & left
CSS BORDER SHORT HAND PROPERTY
It is used to specify the border thickness, style and color of an html
element in a single line
Values: border-width border-style border-color;
border-width:
length
border-style:
solid | double | dotted | dashed | groove | inset | outset | none
border-color:
color name | hex color value | rgb(0,0,0) | transparent
CSS BORDER RADIUS PROPERTIES
CSS border-top-left-radius property: It is used to specify the border top left radius for an html element
Value: length
CSS border-top-right-radius property: It is used to specify the border top right radius for an html element
Value: length
CSS border-bottom-right-radius property: It is used to specify the border bottom right radius for an html
element
Value: length
CSS border-bottom-left-radius property: It is used to specify the border bottom left radius for an html
element
Value: length
CSS border- radius short hand property: It is used to specify the border radius for an html element
Value: Space separated list of values (4, 2, and 1)
4: top-left, top-right, bottom-right, bottom-left
2: top-left & bottom-right, top-right & bottom-left
1: top-left & top-right & bottom-right & bottom-left
CSS MARGIN AREA PROPERTIES
CSS margin-top property: It is used to specify the amount of area to be cleared above an html
element
Values: auto | length | %
CSS margin-right property: It is used to specify the amount of area to be cleared on the right
hand side an html element
Values: auto | length | %
CSS margin-bottom property: It is used to specify the amount of area to be cleared below an
html element
Values: auto | length | %
CSS margin-left property: It is used to specify the amount of area to be cleared on the left hand
side an html element
Values: auto | length | %
CSS margin short hand property: It is used to specify the amount of area to be cleared around an
html element
Values: Space separated list of values (1, 2, 3, and 4)
CSS BORDER RADIUS PROPERTIES
Ex:
margin: 10px;
indicates: margin-top:10px; margin-right:10px; margin-bottom:10px; margin-left:10px;
Ex:
margin: 10px 20px;
indicates: margin-top:10px; margin-bottom:10px; margin-right:20px; margin-left:20px;
Ex:
margin: 10px 20px 10px ;
indicates: margin-top:10px; margin-right:20px; margin-left:20px; margin-bottom:10px;
Ex:
margin: 10px 10px 10px 10px ;
indicates: margin-top:10px; margin-right:10px; margin-bottom:10px; margin-left:10px;
CSS BACKGROUND PROPERTY
CSS background-attachment property: It is used to specify, how the background
image is to be attached to the wall of a web page
Values: scroll | fixed
CSS background-position property: It is used to specify, where the background
image is to be positioned in an html element box.
Values: top left | top center | top right | center left | center center | center right |
bottom left | bottom center | bottom right | x-offset-length y-offset-length | x-offset-
% y-offset-%
CSS background-size property: It is used to specify, background image size
(meaning: width and height)
Values: x-size-length y-size-length | x-size-% auto | cover | contain
CSS BACKGROUND PROPERTY
CSS background-origin property:
It is used to specify, background image origin (meaning: placement) box
Values: content-box | padding-box | border-box
CSS background-clip property:
It is used to specify, background (image & color) clipping (meaning: trim) box
Values: content-box | padding-box
CSS multiple background images : How to use multiple backgrounds?
background-image:url('todown.jpg'),url('flower.png');
background-repeat:repeat-x,repeat-x;
background-position:top left, bottom left;
background-size:100px 50px,32px 32px;
CSS LINEAR GRADIENT BACKGROUND
CSS Linear gradient: is used to create a background consisting of transition
between two or more colors along a straight line.
Syntax:
background: linear-gradient(direction, color-stop1, color-stop2,........., last-color-stop);
OR
background-image: linear-gradient(direction, color-stop1, color-stop2,........., last-color-stop);
direction:
- to left, to right, to top, to bottom ,
- to top left, to top right, to bottom left, to bottom right
- or angle in degrees.
color-stop: color position
- color : color name, hex color value , rgb(0-255,0-255,0-255), rgba(0-255,0-255,0-255,0-1)
- position: px or %
CSS LINEAR GRADIENT BACKGROUND
- Ex:
- background: linear-gradient(to right, red 0%, blue 100%);
- background: linear-gradient(to bottom right, red 0%, blue 100%);
- background: linear-gradient(90deg, red 0%, blue 100%);
- background: linear-gradient(to right, red 0%, green 50%, blue 100%);
- Note: if you use pair of same color side by side you can create color strip
background: linear-gradient(to right, red 0%, red 25%, green 25%,green
50%,blue 50%, blue 100%);
- repeating-linear-gradient
- syntax:
- background: repeating-linear-gradient(direction, color-stop1, color-stop2, ...,
last-color-stop);
- OR
- Background-image: repeating-linear-gradient(direction, color-stop1, color-
stop2, ..., last-color-stop);
- Ex: background: repeating-linear-gradient(90deg,white 0px, white 20px,black
20px, black 40px);
CSS RADIAL GRADIENT BACKGROUND
CSS Radial gradient Background: is a function, used to create a background
consisting of transition between two or more colors that radiates from given origin.
Syntax:
- background: radial-gradient(shape at position, color-stop1, color-stop2, ..., last-color-stop);
OR
- background-image: radial-gradient(shape at position, color-stop1, color-stop2, ..., last-color-stop);
shape at position:
- shape: indicates the shape of gradient i.e. circle, ellipse
- position: indicates the origin of gradient top left, top center, top right center left,
center center, center right bottom left, bottom center, bottom right offset-x-px
offset-y-px offset-x-% offset-y-%
color-stop: color position
- color : color name, hex color value , rgb(0-255,0-255,0-255), rgba(0-255,0-255,0-255,0-1)
- position: px or %
CSS RADIAL GRADIENT BACKGROUND
CSS TRANSFORM PROPERTY
CSS transform property allows you to transform an HTML element
Transform: means translate, rotate, scale and skew
Translate: - means changing position of an html element
Rotate: - means changing orientation of an html element
Scale: - means changing size of an html element
Skew: - means changing slant of an html element
Syntax:
transform: one or more transform functions + perspective function;
CSS TRANSFORM PROPERTY
Perspective function:
- is used to define depth
- perspective(z in pixels)
1D Transform
functions:
2D Transform
functions
3D Transform
functions
translateX(x)
translateY(y)
translateZ(z)
rotateX(x)
rotateY(y)
rotateZ(z)
scaleX(x)
scaleY(y)
scaleZ(z)
skewX(x)
skewY(y)
translate(x,y)
rotate(x,y)
scale(x,y)
skew(x,y)
scale3D(x,y,z)
rotate3D(x,y,z)
translate3D(x,y,z)
CSS TRANSFORM PROPERTY & FUNCTION DEMO
CSS TRANSFORM PROPERTY & FUNCTION DEMO
Example Codes:
transform:perspective(400px) translateX(100px);
transform:perspective(400px) rotateZ(45deg);
transform:perspective(400px) scaleX (2);
transform:perspective(400px) skewX (45deg);
transform:perspective(400px) translate(100px,100px);
transform:perspective(400px) scale(2,0.5);
transform:perspective(400px) translate3D(100px,100px,-100px);
transform:perspective(400px) translateX(100px) rotateZ(45deg) scaleX(2);
CSS TRANSFORM-ORIGIN PROPERTY
CSS transform-origin Property:
- is used to change the position of the pivot point of an html element
- Pivot point is an imaginary point; used to transform an html element in
different ways
CSS TRANSITIONS
Transition:
- means changing the state of an HTML element smoothly
- Using CSS transition properties instead of suddenly changing the state of an HTML element; we
can change the state of an HTML element smoothly
Applying CSS transitions:
- transition-property: - comma separated one or more CSS properties to be
transitioned , none, all transition-duration
- comma separated one or more time in ms/s taken to complete the transition transition-timing-
function:
- comma separated one or more behaviors of transition (linear, ease-in, ease-out, ease-in-out)
transition-delay: - comma separated one or more time delays in ms/s to begin the transition
transition:
- comma separated one or more
- [transition-property transition-duration transition-timing-function transition-delay]
- Note: CSS Transitions allow us to change the state of an HTML element from initial state to the
final state; does not allow controlling in-between states; to add and control in-between states
we take help of CSS Animations.
CSS TRANSITIONS
Example Code:
#div1
{
width:100px;
height:100px;
border:1px solid black;
transform:rotateZ(0deg);
background-color:red; color:white;
/*
transition-property:transform,background-color;
transition-duration:2s,2s;
transition-timing-function:linear,linear;
transition-delay:0s,0s;
*/
transition:transform 2s linear 0s, background-color 2s linear 0s;
}
#div1:hover
{
transform:rotateZ(90deg);
background-color:green;
}
CSS ANIMATIONS PROPERTY
Allow us to animate sequence of HTML element states over a given period of time
To animate sequence of HTML element states we take help of @keyframes block
APPLYING ANIMATION PROPERTIES
1. animation-name: - comma separated one or more @keyframes block's names
2. animation-duration: - comma separated one or more time in ms/s taken to
complete the animation
3. animation-timing-function: - comma separated one of more behaviors of
animation (linear, ease-in, ease-out, ease-in-out)
4. animation-delay: - comma separated one or more time delays in ms/s to
begin the animation
5. animation-iteration-count: - comma separated one or more numbers
indicating number of times animation to be played, infinite
6. animation-direction: - comma separated one or more directions for the
animation (normal, reverse, alternate, alternate-reverse)
7. animation: comma separated one or more
[animation-[ name duration timing-function delay iteration-count direction]],..
APPLYING ANIMATION PROPERTIES
Example Code:
@keyframes animateBgColor
{
0%{background-color:white;}
25%{background-color:red;}
50%{background-color:green;}
75%{background-color:blue;}
100%{background-color:white;}
}
@keyframes animateRotation
{
0%{transform:rotateZ(0deg);}
25%{transform:rotateZ(90deg);}
50%{transform:rotateZ(180deg);}
75%{transform:rotateZ(270deg);}
100%{transform:rotateZ(360deg);}
}
CSS FLOAT AND CLEAR PROPERTIES
1. Used to create web page layouts
2. float: left, right, none - is used to float an element either to the left
or to the right in its parent element
3. float:left; - floats an element to the left in its parent element
4. float:right; - floats an element to the right in its parent element
5. float:none; - is used remove float effect from an already floated
element
6. clear: left, right, both - is used to clear the effect of floating on the
parent element
7. clear:left; - clears the effect of floating left on its parent element
8. clear:right; - clears the effect of floating right on its parent
element
9. clear:both; - clears the effect of floating left & right on its parent
element
CSS FLOAT AND CLEAR PROPERTIES
Example Code:
div#parent1 {
border:1px solid black;
}
div#div1 {
width:100px;
height:100px;
background-color:blue;
float:left;
}
div#div2{
width:100px;
height:100px;
background-color:gray;
float:left;
}
div#div3 {
width:100px;
height:100px;
background-color:green; f
loat:left;
}
.clear-left::after { content:""; display:block; clear:left; }
div#parent2 {
border:1px solid black;
}
div#div4 {
width:100px;
height:100px;
background-color:blue;
float:right;
}
div#div5 {
width:100px;
height:100px;
background-color:gray;
float:right;
}
div#div6 {
width:100px;
height:100px;
background-color:green;
float:right; }
.clear-right::after { content:""; display:block;
clear:right; }
div#parent3 {
border:1px solid black;
}
div#div7 {
width:100px;
height:100px;
background-color:blue;
float:left;
}
div#div8 {
width:100px;
height:100px;
background-color:gray;
float:left;
}
div#div9 {
width:100px;
height:100px;
background-color:green;
float:right;
}
div#div10 {
width:100px;
height:100px;
background-color:orange;
float:right; }
.clear-both::after { content:""; display:block;
clear:both; }
CSS POSITION PROPERTY
The position property determines in what manner an item is positioned on the page or relative
to one another. By default position is set to static, with elements displaying on the page in the
order they appear in the document, but let’s take a look at some other position styles.
STATIC — Element displays on the page in the order it appeared in the document. Top, right,
bottom, left, and z-index properties have no effect when used with static. Not stackable due to z-
index restriction.
RELATIVE — Similar to static but able to be offset by top, right, bottom, left, and z-index
properties.
ABSOLUTE — Element positioned relative to its first non-static ancestor element. Similar to
relative in that it may be offset by top, right, bottom, left, and z-index properties.
FIXED — Similar to absolute, but positioned relative to the browser window. Scrolling will not
move this element.
STICKY — Element is positioned relative until a specified offset position is met by scrolling,
then the element is positioned ‘fixed’ in that position on the scrolling element.
CSS POSITION PROPERTY - STATIC
- is used to position an HTML element in an HTML
- document values: static, relative, absolute, fixed & sticky
- position : static;
- HTML elements are displayed as they appear in the normal document flow
- by default all html element's position property is set to static
- as the name itself indicates, static elements cannot be moved i.e. static elements are
not affected by left, right, bottom, top, and z-index properties.
Note: while using position property; we take help of left, right,
bottom, top and z-index properties to position an HTML element.
EXAMPLE CODE - STATIC
CSS POSITION PROPERTY - RELATIVE
- is used to position an HTML element in an HTML
- document values: static, relative, absolute, fixed & sticky
- position: relative; - is used to position an HTML element relative to its normal
position
- Note: while using position property; we take help of left, right, bottom, top and
z-index properties to position an HTML element.
CSS POSITION PROPERTY - RELATIVE
CSS POSITION PROPERTY - ABSOLUTE
- is used to position an HTML element in an HTML
- document values: static, relative, absolute, fixed & sticky
- position: absolute; - is used to position an HTML element relative to the edges
of it's first positioned ancestor or relative to the edges of the browser’s
viewport
- Note: while using position property; we take help of left, right, bottom, top
and z-index properties to position an HTML element.
CSS POSITION PROPERTY-ABSOLUTE
CSS POSITION PROPERTY - FIXED
CSS position property: - is used to position an HTML element in a document
values: static, relative, absolute, fixed & sticky
position: fixed; - is used to position and pin (or fix) an HTML element relative to the edges of
the browser’s viewport
Note: while using position property; we take help of left, right, bottom, top and z-index
properties to position an HTML element.
CSS POSITION PROPERTY FIXED
CSS POSITION PROPERTY - STICKY
- is used to position an HTML element in an HTML document
- values: static, relative, absolute, fixed & sticky
- position: sticky; - is used to position and stick an HTML element relative to top edge of the
browser viewport
- Note: while using position property; we take help of left, right, bottom, top and z-index
properties to position an HTML element.
CSS POSITION PROPERTY STICKY
CSS Z-INDEX PROPERTY
- is used to position an HTML element in an HTML document
- values: static, relative, absolute, fixed & sticky
- W.K.T. while positioning HTML elements; we take help of left, right, bottom,
top and z-index properties.
- CSS z-index property: - is used to control the displaying order of overlapping
positioned HTML elements
- Note: - an HTML element with lower z-index value is displayed behind an
HTML element with higher z-index value
CSS Z-INDEX PROPERTY
CSS DISPLAY PROPERTY
When you create an element to display on the page, it renders as a box & we
have seen how to position those boxes on the page, but there’s more we can do
with them. CSS’s Display property specifies the type of rendering box that is
created from our HTML. Let’s check out some of the different display styles we
can use.
BLOCK — Element starts on a new line & takes up the entire width. May contain other block or
inline elements. Elements that are block-level by default include <div>, <p>, <h1>-<h6>, <ul>,
<li>, & <canvas>.
INLINE —Element can start anywhere on an existing line. Height and width properties have no
effect. Elements that are inline by default include <span>, <input>, <button>, &<img>.
GRID — Element is displayed block-level with inner content in grid layout.
FLEX — Element is displayed block-level with inner content in flexbox layout.
INLINE-BLOCK — Element is displayed inline but height and width may be defined. May also be
used with grid, flex, or table as these are block-level elements.
NONE — Removes this element & all children (to just make an item invisible but still take up
space on the page use the visibility property)
CSS FLEXBOX AND GRID LAYOUT PROPERTY
CSS FLEXBOX LAYOUT PROPERTY
CSS FLEXBOX LAYOUT PROPERTY
Property #1: Display: Flex
CSS FLEXBOX LAYOUT PROPERTY
Property #1: Display: Flex
CSS FLEXBOX LAYOUT PROPERTY
Property #2: Flex Direction
CSS FLEXBOX LAYOUT PROPERTY
Property #2: Flex Direction
CSS FLEXBOX LAYOUT PROPERTY
Property #3: Justify Content
CSS FLEXBOX LAYOUT PROPERTY
Property #4: Align Items
CSS FLEXBOX LAYOUT PROPERTY
Property #4: Align Items
CSS FLEXBOX LAYOUT PROPERTY
Property #5: Align Self
5. Web Technology CSS Advanced

Contenu connexe

Tendances (6)

Css advanced – session 4
Css advanced – session 4Css advanced – session 4
Css advanced – session 4
 
CSS - Basics
CSS - BasicsCSS - Basics
CSS - Basics
 
The Ring programming language version 1.4 book - Part 13 of 30
The Ring programming language version 1.4 book - Part 13 of 30The Ring programming language version 1.4 book - Part 13 of 30
The Ring programming language version 1.4 book - Part 13 of 30
 
DrawingML Subject: Shape Properties & Effects
DrawingML Subject: Shape Properties & EffectsDrawingML Subject: Shape Properties & Effects
DrawingML Subject: Shape Properties & Effects
 
Css
CssCss
Css
 
CSS3 notes
CSS3 notesCSS3 notes
CSS3 notes
 

Similaire à 5. Web Technology CSS Advanced

Similaire à 5. Web Technology CSS Advanced (20)

CSS Cascade Style Sheet
CSS Cascade Style SheetCSS Cascade Style Sheet
CSS Cascade Style Sheet
 
Css
CssCss
Css
 
Css
CssCss
Css
 
Web - CSS 1.pptx
Web - CSS 1.pptxWeb - CSS 1.pptx
Web - CSS 1.pptx
 
Cascading Style Sheets
Cascading Style SheetsCascading Style Sheets
Cascading Style Sheets
 
Pemrograman Web 2 - CSS
Pemrograman Web 2 - CSSPemrograman Web 2 - CSS
Pemrograman Web 2 - CSS
 
Css
CssCss
Css
 
Basic css
Basic cssBasic css
Basic css
 
Web Programming& Scripting Lab
Web Programming& Scripting LabWeb Programming& Scripting Lab
Web Programming& Scripting Lab
 
Web Design Course: CSS lecture 3
Web Design Course: CSS lecture 3Web Design Course: CSS lecture 3
Web Design Course: CSS lecture 3
 
Deep Dive into Line-Height
Deep Dive into Line-HeightDeep Dive into Line-Height
Deep Dive into Line-Height
 
Cascading style sheets (CSS-Web Technology)
Cascading style sheets (CSS-Web Technology)Cascading style sheets (CSS-Web Technology)
Cascading style sheets (CSS-Web Technology)
 
2_css.pptx
2_css.pptx2_css.pptx
2_css.pptx
 
2_css.pptx
2_css.pptx2_css.pptx
2_css.pptx
 
Cascstylesheets
CascstylesheetsCascstylesheets
Cascstylesheets
 
CSS
CSSCSS
CSS
 
Introduction to css by programmerblog.net
Introduction to css by programmerblog.netIntroduction to css by programmerblog.net
Introduction to css by programmerblog.net
 
IT2255 Web Essentials - Unit II Web Designing
IT2255 Web Essentials - Unit II  Web DesigningIT2255 Web Essentials - Unit II  Web Designing
IT2255 Web Essentials - Unit II Web Designing
 
Css
CssCss
Css
 
3. CSS
3. CSS3. CSS
3. CSS
 

Plus de Jyoti Yadav (13)

8. Deep Learning.pdf
8. Deep Learning.pdf8. Deep Learning.pdf
8. Deep Learning.pdf
 
7. Reinforcement Learning.pdf
7. Reinforcement Learning.pdf7. Reinforcement Learning.pdf
7. Reinforcement Learning.pdf
 
6. Association Rule.pdf
6. Association Rule.pdf6. Association Rule.pdf
6. Association Rule.pdf
 
4. Classification.pdf
4. Classification.pdf4. Classification.pdf
4. Classification.pdf
 
3. Regression.pdf
3. Regression.pdf3. Regression.pdf
3. Regression.pdf
 
2. Data Preprocessing.pdf
2. Data Preprocessing.pdf2. Data Preprocessing.pdf
2. Data Preprocessing.pdf
 
1. Demystifying ML.pdf
1. Demystifying ML.pdf1. Demystifying ML.pdf
1. Demystifying ML.pdf
 
6. Web Publishing
6. Web Publishing6. Web Publishing
6. Web Publishing
 
4. Web Technology CSS Basics-1
4. Web Technology CSS Basics-14. Web Technology CSS Basics-1
4. Web Technology CSS Basics-1
 
3. Web Technology Advanced HTML
3. Web Technology Advanced HTML3. Web Technology Advanced HTML
3. Web Technology Advanced HTML
 
2b. Web Technology HTML Basics-2
2b. Web Technology HTML Basics-22b. Web Technology HTML Basics-2
2b. Web Technology HTML Basics-2
 
2a web technology html basics 1
2a web technology html basics 12a web technology html basics 1
2a web technology html basics 1
 
1. web technology basics
1. web technology basics1. web technology basics
1. web technology basics
 

Dernier

會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
中 央社
 

Dernier (20)

Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...
 
Chapter 7 Pharmacosy Traditional System of Medicine & Ayurvedic Preparations ...
Chapter 7 Pharmacosy Traditional System of Medicine & Ayurvedic Preparations ...Chapter 7 Pharmacosy Traditional System of Medicine & Ayurvedic Preparations ...
Chapter 7 Pharmacosy Traditional System of Medicine & Ayurvedic Preparations ...
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge App
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
II BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING II
II BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING IIII BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING II
II BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING II
 
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
 
philosophy and it's principles based on the life
philosophy and it's principles based on the lifephilosophy and it's principles based on the life
philosophy and it's principles based on the life
 
PSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxPSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptx
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
Word Stress rules esl .pptx
Word Stress rules esl               .pptxWord Stress rules esl               .pptx
Word Stress rules esl .pptx
 
Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).
 
Benefits and Challenges of OER by Shweta Babel.pptx
Benefits and Challenges of OER by Shweta Babel.pptxBenefits and Challenges of OER by Shweta Babel.pptx
Benefits and Challenges of OER by Shweta Babel.pptx
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 

5. Web Technology CSS Advanced

  • 1. WEB TECHNOLOGY CASCADING STYLE SHEET ADVANCED DR. JYOTI YADAV
  • 2. CSS NOT (NEGATION) PSEUDO CLASS Syntax of not pseudo class selector: selector : not(argument) { declaration list; } It selects any html element targeted by the selector, if it does not match the argument passed to not pseudo class. Ex: p : not(.first) { border : 2px dotted blue; } It selects any p element, if it has no class attribute value set to first. Ex: input : not(:disabled) { border : 2px dotted blue; } It selects any input element,if it is not disabled
  • 3. CSS – PSEUDO ELEMENTS Ex: p::before { content : ”Hello “; } It generates the specified content (i.e. Hello) before the content of any p element. Ex: p::after { content : ” HTML!“; } It generates the specified content (i.e. HTML!) after the content of any p element.
  • 4. CSS SPECIFICITY RULES What happens when we define set of style rules for a specific tag in external, internal as well as inline styles? The answer is:“rules get’s cascade” The rules of the cascade include: More specific selector’s properties override less specific selector’s properties. Nearest properties override farthest properties, when specificity is equivalent. Finally for every tag a virtual declaration list is created by combining all properties from all selectors
  • 5. CSS UNIVERSAL SELECTOR(*) It is used to target any html element on page and apply styles on it. Syntax of universal Selector: * { declaration list; } It targets to any html element on the page Ex: * { border:2px solid red; } It selects every html element on the page and applies 2px solid red border *.firsttwo { border:2px solid red; } It selects any html element which has class attribute value set to firsttwo
  • 6. CSS UNIVERSAL SELECTOR(*) *#container { border:2px solid red; } It selects any html element which has id attribute value set to container * > p { border:2px solid red; } It selects any p element which is the direct child of any html element
  • 7. CSS PROPERTIES 1. Font-weight Property: It used to specify the boldness of the font. Values: lighter | normal | bold | bolder | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 2. Font-style Property: It used to specify the style of the text to be displayed. Values: normal | italic | oblique (more italic) 3. Text-decoration Property: It used to specify the line formatting of the text to be displayed Values: none | underline | line-through | overline 4. Content Property: It is used to generate content dynamically at run time. Values:“string” | open-quote | close-quote | url(“filepath”) | none
  • 8. CSS PROPERTIES 5. background-color property: It is used to specify the background color for any html element Values: color name | hex value | rgb(0-255,0-255,0-255) | rgba(0-255,0-255,0-255,0-1) | transparent 6. font-size property: It is used to specify the size of the font Values: xx-small | x-small | smaller | small | medium | large | larger | x-large | xx-large | length (pt, px , em, %) 7. text-align property: It is used to align the text horizontally Values: left | center | right | justify
  • 9. 7. CSS FONT-SIZE PROPERTY VS HTML FONT TAG SIZE ATTRIBUTE It is used to specify the size of the font to be applied Values: xx-small | x-small | smaller | small | medium | large | larger | x-large | xx-large | length | % Note:16px = 1em (px to em Ex: 10px / 16px = 0.625em) size=1 == font-size:x-small == font-size:10px == font-size:0.625em size=2 == font-size:small == font-size:13px == font-size:0.8125em size=3 == font-size:medium == font-size:16px == font-size:1.0em size=4 == font-size:large == font-size:18px == font-size:1.125em size=5 == font-size:x-large == font-size:24px == font-size:1.5em size=6 == font-size:xx-large == font-size:32px == font-size:2.0em size=7 == == font-size:48px == font-size:3.0em
  • 10. 8. CSS COLOR PROPERTY VS HTML FONT TAG COLOR ATTRIBUTE It is used to specify the text color to be applied Values: color name | hex value | rgb(0-255,0-255,0-255) | rgba(0-255,0- 255,0-255,0-1) | transparent color name = ex: red, green, blue etc. hex color value = ex: #ff0000, #00ff00, #0000ff etc. rdb() = ex: rgb(255,0,0), rgb(0,255,0), rgb(0,0,255) etc. rgba() = ex: rgba(255,0,0,1), rgba(0,255,0,1), rgba(0,0,255,1) etc.
  • 11. 9. CSS FONT-FAMILY PROPERTY VS HTML FONT TAG FACE ATTRIBUTE It used to specify the font to be applied to the content of an HTML element Values: specific font name (i.e. font face), specific font family name, generic font family name Ex: font-family :‘Arial Black’; font-family :‘Arial Black’,Arial; font-family :‘Arial Black’,Arial, sans-serif;
  • 12. CSS FONT-FAMILY PROPERTY VS HTML FONT TAG FACE ATTRIBUTE 10. text-indent property: It is used to specify the indentation of the first line in the paragraph Values: length 11. text-align property: It is used to specify the horizontal alignment of the text Values: left | center | right | justify 12. text-align-last property: It is used to specify the horizontal alignment of the last line in the paragraph Values: left | center | right | justify 13. letter-spacing property: It is used to specify the space between the letters or characters Values: length 14. word-spacing property: It is used to specify the space between the words Values: length 15. line-height property: It is used to specify the space above and below the text Values: length
  • 13. CSS FONT-FAMILY PROPERTY VS HTML FONT TAG FACE ATTRIBUTE 16. text-transform property: It is used to specify the text case to be applied Values: uppercase | lowercase | capitalize 17. font-variant property: It is used to specify the text case to be applied Values: small-caps | normal 18. text-shadow property: It is used to apply shadow effect to the text of an html element Value: shadow-x-offset shadow-y-offset shadow-color-spread-amount shadow-color; 19. box-shadow property: It is used to apply shadow effect to the html element (rectangle box area) Value: shadow-x-offset shadow-y-offset shadow-color-spread-amount shadow-color;
  • 14. CSS FONT-FAMILY PROPERTY VS HTML FONT TAG FACE ATTRIBUTE 20. list-style-type property: It is used to specify the bullet symbol to be displayed in front of list items of html ol or html ul. Values: decimal | decimal-leading-zero | upper-alpha | lower-alpha | upper-roman | lower- roman | none | disc | circle | square etc. 21. list-style-image property: It is used to specify the image to be used as a bullet symbol Value: url(‘image path’); Note: image size should be 12 x 12 22. list-style-position property: It is used to specify the position of the bullet symbol with respect to list item’s border area. Values: outside | inside
  • 15. CSS BOX MODEL HTML box with its component areas: CSS Content area:The amount of space required to display the content or the area occupied by the content It is determined by CSS width property and CSS height property CSS Padding area:The distance between the content and the border.The empty space or empty area around the content. It is determined by CSS padding property CSS Border area: The area occupied by the border.The area around the padding meant to display border. It is determined by CSS border property. CSS Margin area:The area around the border.The empty space or empty area around the border. It is determined by CSS margin property
  • 16. CSS BOX MODEL Calculating actual width and actual height of an HTML element: HTML element's actual width: is the amount of space occupied by an HTML element horizontally Actual width of an HTML element = content width + left padding + right padding + left border + right border + left margin + right margin HTML element's actual height: is the amount of space occupied by an HTML element vertically Actual height of an HTML element = content height + top padding + bottom padding + top border + bottom border + top margin + bottom margin
  • 17. CSS CONTENT AREA PROPERTIES CSS width property: It is used to specify, width of content area Values: auto | length | % CSS height property: It is used to specify, height of content area Values: auto | length | % CSS overflow property: It is used to specify, how the overflowed content to be displayed Values: visible | hidden | scroll CSS overflow-x property: It is used to specify, whether the horizontal scroll bar to be visible or hidden Values: visible | hidden CSS overflow-y property: It is used to specify, whether the vertical scroll bar to be visible or hidden Values: visible | hidden
  • 18. CSS PADDING AREA PROPERTIES CSS padding-top property: It is used to specify the amount of area to be cleared above the content area of an html element Values: length | % CSS padding-right property: It is used to specify the amount of area to be cleared on the right hand side of the content area of an html element Values: length | % CSS padding-bottom property: It is used to specify the amount of area to be cleared below the content area of an html element Values: length | % CSS padding-left property: It is used to specify the amount of area to be cleared on the left hand side of the content area of an html element Values: length | % CSS padding short hand property: It is used to specify the amount of area to be cleared around the content area of an html element Values: space separated list values (1, 2, 3, and 4)
  • 19. CSS PADDING AREA PROPERTIES Ex: padding: 10px; indicates: padding-top:10px; padding-right:10px; padding-bottom:10px; padding- left:10px; Ex: padding: 10px 20px; indicates: padding-top:10px; padding-bottom:10px; padding-right:20px; padding- left:20px; Ex: padding: 10px 20px 10px ; indicates: padding-top:10px; padding-right:20px; padding-left:20px; padding- bottom:10px; Ex: padding: 10px 10px 10px 10px ; indicates: padding-top:10px; padding-right:10px; padding-bottom:10px; padding- left:10px;
  • 20. CSS BORDER AREA PROPERTIES CSS border-top-width property: It is used to specify the thickness of the top border of an html element Values: length CSS border-top-style property: It is used to specify the style of the top border of an html element Values: solid | double | dotted | dashed | groove | inset | outset | none v CSS border-top-color property: It is used to specify the color of the top border of an html element Values: color CSS border-right-width property: It is used to specify the thickness of the right border of an html element Values: length CSS border-right-style property: It is used to specify the style of the right border of an html element Values: solid | double | dotted | dashed | groove | inset | outset | none CSS border-right-color property: It is used to specify the color of the right border of an html element Values: color | hex color value CSS border-bottom-width property:It is used to specify the thickness of the bottom border of an html element Values: length
  • 21. CSS BORDER AREA PROPERTIES CSS border- bottom -style property: It is used to specify the style of the bottom border of an html element Values: solid | double | dotted | dashed | groove | inset | outset | none CSS border- bottom -color property: It is used to specify the color of the bottom border of an html element Values: color | hex color value CSS border-left-width property: It is used to specify the thickness of the left border of an html element Values: length CSS border-left-style property: It is used to specify the style of the left border of an html element Values: solid | double | dotted | dashed | groove | inset | outset | none CSS border-left-color property: It is used to specify the color of the left border of an html element Values: color | hex color value
  • 22. CSS BORDER PROPERTIES CSS border-top short hand property: It is used to specify the top border thickness, style and color in a single line Values: border-top-width border-top-style border-top-color; CSS border-right short hand property: It is used to specify the right border thickness, style and color in a single line Values: border-right-width border-right-style border-right-color; CSS border- bottom short hand property: It is used to specify the bottom border thickness, style and color in a single line Values: border- bottom -width border- bottom -style border- bottom -color; CSS border-left short hand property: It is used to specify the left border thickness, style and color in a single line Values: border-left-width border-left-style border-left-color;
  • 23. CSS BORDER PROPERTIES CSS border-width property: It is used to specify the thickness of the border of an html element Values: Space separated list of values (1, 2, 3 and 4) CSS border-style property: It is used to specify the style of the border of an html element Values: Space separated list of values (1, 2, 3 and 4) CSS border-color property: It is used to specify the color of the border of an html element Values: Space separated list of values (1, 2, 3 and 4) 4: top, right, bottom, left 3: top, right & left, bottom 2: top & bottom, right & left 1: top & right & bottom & left
  • 24. CSS BORDER SHORT HAND PROPERTY It is used to specify the border thickness, style and color of an html element in a single line Values: border-width border-style border-color; border-width: length border-style: solid | double | dotted | dashed | groove | inset | outset | none border-color: color name | hex color value | rgb(0,0,0) | transparent
  • 25. CSS BORDER RADIUS PROPERTIES CSS border-top-left-radius property: It is used to specify the border top left radius for an html element Value: length CSS border-top-right-radius property: It is used to specify the border top right radius for an html element Value: length CSS border-bottom-right-radius property: It is used to specify the border bottom right radius for an html element Value: length CSS border-bottom-left-radius property: It is used to specify the border bottom left radius for an html element Value: length CSS border- radius short hand property: It is used to specify the border radius for an html element Value: Space separated list of values (4, 2, and 1) 4: top-left, top-right, bottom-right, bottom-left 2: top-left & bottom-right, top-right & bottom-left 1: top-left & top-right & bottom-right & bottom-left
  • 26. CSS MARGIN AREA PROPERTIES CSS margin-top property: It is used to specify the amount of area to be cleared above an html element Values: auto | length | % CSS margin-right property: It is used to specify the amount of area to be cleared on the right hand side an html element Values: auto | length | % CSS margin-bottom property: It is used to specify the amount of area to be cleared below an html element Values: auto | length | % CSS margin-left property: It is used to specify the amount of area to be cleared on the left hand side an html element Values: auto | length | % CSS margin short hand property: It is used to specify the amount of area to be cleared around an html element Values: Space separated list of values (1, 2, 3, and 4)
  • 27. CSS BORDER RADIUS PROPERTIES Ex: margin: 10px; indicates: margin-top:10px; margin-right:10px; margin-bottom:10px; margin-left:10px; Ex: margin: 10px 20px; indicates: margin-top:10px; margin-bottom:10px; margin-right:20px; margin-left:20px; Ex: margin: 10px 20px 10px ; indicates: margin-top:10px; margin-right:20px; margin-left:20px; margin-bottom:10px; Ex: margin: 10px 10px 10px 10px ; indicates: margin-top:10px; margin-right:10px; margin-bottom:10px; margin-left:10px;
  • 28. CSS BACKGROUND PROPERTY CSS background-attachment property: It is used to specify, how the background image is to be attached to the wall of a web page Values: scroll | fixed CSS background-position property: It is used to specify, where the background image is to be positioned in an html element box. Values: top left | top center | top right | center left | center center | center right | bottom left | bottom center | bottom right | x-offset-length y-offset-length | x-offset- % y-offset-% CSS background-size property: It is used to specify, background image size (meaning: width and height) Values: x-size-length y-size-length | x-size-% auto | cover | contain
  • 29. CSS BACKGROUND PROPERTY CSS background-origin property: It is used to specify, background image origin (meaning: placement) box Values: content-box | padding-box | border-box CSS background-clip property: It is used to specify, background (image & color) clipping (meaning: trim) box Values: content-box | padding-box CSS multiple background images : How to use multiple backgrounds? background-image:url('todown.jpg'),url('flower.png'); background-repeat:repeat-x,repeat-x; background-position:top left, bottom left; background-size:100px 50px,32px 32px;
  • 30. CSS LINEAR GRADIENT BACKGROUND CSS Linear gradient: is used to create a background consisting of transition between two or more colors along a straight line. Syntax: background: linear-gradient(direction, color-stop1, color-stop2,........., last-color-stop); OR background-image: linear-gradient(direction, color-stop1, color-stop2,........., last-color-stop); direction: - to left, to right, to top, to bottom , - to top left, to top right, to bottom left, to bottom right - or angle in degrees. color-stop: color position - color : color name, hex color value , rgb(0-255,0-255,0-255), rgba(0-255,0-255,0-255,0-1) - position: px or %
  • 31. CSS LINEAR GRADIENT BACKGROUND - Ex: - background: linear-gradient(to right, red 0%, blue 100%); - background: linear-gradient(to bottom right, red 0%, blue 100%); - background: linear-gradient(90deg, red 0%, blue 100%); - background: linear-gradient(to right, red 0%, green 50%, blue 100%); - Note: if you use pair of same color side by side you can create color strip background: linear-gradient(to right, red 0%, red 25%, green 25%,green 50%,blue 50%, blue 100%); - repeating-linear-gradient - syntax: - background: repeating-linear-gradient(direction, color-stop1, color-stop2, ..., last-color-stop); - OR - Background-image: repeating-linear-gradient(direction, color-stop1, color- stop2, ..., last-color-stop); - Ex: background: repeating-linear-gradient(90deg,white 0px, white 20px,black 20px, black 40px);
  • 32. CSS RADIAL GRADIENT BACKGROUND CSS Radial gradient Background: is a function, used to create a background consisting of transition between two or more colors that radiates from given origin. Syntax: - background: radial-gradient(shape at position, color-stop1, color-stop2, ..., last-color-stop); OR - background-image: radial-gradient(shape at position, color-stop1, color-stop2, ..., last-color-stop); shape at position: - shape: indicates the shape of gradient i.e. circle, ellipse - position: indicates the origin of gradient top left, top center, top right center left, center center, center right bottom left, bottom center, bottom right offset-x-px offset-y-px offset-x-% offset-y-% color-stop: color position - color : color name, hex color value , rgb(0-255,0-255,0-255), rgba(0-255,0-255,0-255,0-1) - position: px or %
  • 33. CSS RADIAL GRADIENT BACKGROUND
  • 34. CSS TRANSFORM PROPERTY CSS transform property allows you to transform an HTML element Transform: means translate, rotate, scale and skew Translate: - means changing position of an html element Rotate: - means changing orientation of an html element Scale: - means changing size of an html element Skew: - means changing slant of an html element Syntax: transform: one or more transform functions + perspective function;
  • 35. CSS TRANSFORM PROPERTY Perspective function: - is used to define depth - perspective(z in pixels) 1D Transform functions: 2D Transform functions 3D Transform functions translateX(x) translateY(y) translateZ(z) rotateX(x) rotateY(y) rotateZ(z) scaleX(x) scaleY(y) scaleZ(z) skewX(x) skewY(y) translate(x,y) rotate(x,y) scale(x,y) skew(x,y) scale3D(x,y,z) rotate3D(x,y,z) translate3D(x,y,z)
  • 36. CSS TRANSFORM PROPERTY & FUNCTION DEMO
  • 37. CSS TRANSFORM PROPERTY & FUNCTION DEMO Example Codes: transform:perspective(400px) translateX(100px); transform:perspective(400px) rotateZ(45deg); transform:perspective(400px) scaleX (2); transform:perspective(400px) skewX (45deg); transform:perspective(400px) translate(100px,100px); transform:perspective(400px) scale(2,0.5); transform:perspective(400px) translate3D(100px,100px,-100px); transform:perspective(400px) translateX(100px) rotateZ(45deg) scaleX(2);
  • 38. CSS TRANSFORM-ORIGIN PROPERTY CSS transform-origin Property: - is used to change the position of the pivot point of an html element - Pivot point is an imaginary point; used to transform an html element in different ways
  • 39. CSS TRANSITIONS Transition: - means changing the state of an HTML element smoothly - Using CSS transition properties instead of suddenly changing the state of an HTML element; we can change the state of an HTML element smoothly Applying CSS transitions: - transition-property: - comma separated one or more CSS properties to be transitioned , none, all transition-duration - comma separated one or more time in ms/s taken to complete the transition transition-timing- function: - comma separated one or more behaviors of transition (linear, ease-in, ease-out, ease-in-out) transition-delay: - comma separated one or more time delays in ms/s to begin the transition transition: - comma separated one or more - [transition-property transition-duration transition-timing-function transition-delay] - Note: CSS Transitions allow us to change the state of an HTML element from initial state to the final state; does not allow controlling in-between states; to add and control in-between states we take help of CSS Animations.
  • 40. CSS TRANSITIONS Example Code: #div1 { width:100px; height:100px; border:1px solid black; transform:rotateZ(0deg); background-color:red; color:white; /* transition-property:transform,background-color; transition-duration:2s,2s; transition-timing-function:linear,linear; transition-delay:0s,0s; */ transition:transform 2s linear 0s, background-color 2s linear 0s; } #div1:hover { transform:rotateZ(90deg); background-color:green; }
  • 41. CSS ANIMATIONS PROPERTY Allow us to animate sequence of HTML element states over a given period of time To animate sequence of HTML element states we take help of @keyframes block
  • 42. APPLYING ANIMATION PROPERTIES 1. animation-name: - comma separated one or more @keyframes block's names 2. animation-duration: - comma separated one or more time in ms/s taken to complete the animation 3. animation-timing-function: - comma separated one of more behaviors of animation (linear, ease-in, ease-out, ease-in-out) 4. animation-delay: - comma separated one or more time delays in ms/s to begin the animation 5. animation-iteration-count: - comma separated one or more numbers indicating number of times animation to be played, infinite 6. animation-direction: - comma separated one or more directions for the animation (normal, reverse, alternate, alternate-reverse) 7. animation: comma separated one or more [animation-[ name duration timing-function delay iteration-count direction]],..
  • 43. APPLYING ANIMATION PROPERTIES Example Code: @keyframes animateBgColor { 0%{background-color:white;} 25%{background-color:red;} 50%{background-color:green;} 75%{background-color:blue;} 100%{background-color:white;} } @keyframes animateRotation { 0%{transform:rotateZ(0deg);} 25%{transform:rotateZ(90deg);} 50%{transform:rotateZ(180deg);} 75%{transform:rotateZ(270deg);} 100%{transform:rotateZ(360deg);} }
  • 44. CSS FLOAT AND CLEAR PROPERTIES 1. Used to create web page layouts 2. float: left, right, none - is used to float an element either to the left or to the right in its parent element 3. float:left; - floats an element to the left in its parent element 4. float:right; - floats an element to the right in its parent element 5. float:none; - is used remove float effect from an already floated element 6. clear: left, right, both - is used to clear the effect of floating on the parent element 7. clear:left; - clears the effect of floating left on its parent element 8. clear:right; - clears the effect of floating right on its parent element 9. clear:both; - clears the effect of floating left & right on its parent element
  • 45. CSS FLOAT AND CLEAR PROPERTIES
  • 46. Example Code: div#parent1 { border:1px solid black; } div#div1 { width:100px; height:100px; background-color:blue; float:left; } div#div2{ width:100px; height:100px; background-color:gray; float:left; } div#div3 { width:100px; height:100px; background-color:green; f loat:left; } .clear-left::after { content:""; display:block; clear:left; } div#parent2 { border:1px solid black; } div#div4 { width:100px; height:100px; background-color:blue; float:right; } div#div5 { width:100px; height:100px; background-color:gray; float:right; } div#div6 { width:100px; height:100px; background-color:green; float:right; } .clear-right::after { content:""; display:block; clear:right; }
  • 47. div#parent3 { border:1px solid black; } div#div7 { width:100px; height:100px; background-color:blue; float:left; } div#div8 { width:100px; height:100px; background-color:gray; float:left; } div#div9 { width:100px; height:100px; background-color:green; float:right; } div#div10 { width:100px; height:100px; background-color:orange; float:right; } .clear-both::after { content:""; display:block; clear:both; }
  • 48. CSS POSITION PROPERTY The position property determines in what manner an item is positioned on the page or relative to one another. By default position is set to static, with elements displaying on the page in the order they appear in the document, but let’s take a look at some other position styles. STATIC — Element displays on the page in the order it appeared in the document. Top, right, bottom, left, and z-index properties have no effect when used with static. Not stackable due to z- index restriction. RELATIVE — Similar to static but able to be offset by top, right, bottom, left, and z-index properties. ABSOLUTE — Element positioned relative to its first non-static ancestor element. Similar to relative in that it may be offset by top, right, bottom, left, and z-index properties. FIXED — Similar to absolute, but positioned relative to the browser window. Scrolling will not move this element. STICKY — Element is positioned relative until a specified offset position is met by scrolling, then the element is positioned ‘fixed’ in that position on the scrolling element.
  • 49. CSS POSITION PROPERTY - STATIC - is used to position an HTML element in an HTML - document values: static, relative, absolute, fixed & sticky - position : static; - HTML elements are displayed as they appear in the normal document flow - by default all html element's position property is set to static - as the name itself indicates, static elements cannot be moved i.e. static elements are not affected by left, right, bottom, top, and z-index properties. Note: while using position property; we take help of left, right, bottom, top and z-index properties to position an HTML element.
  • 50. EXAMPLE CODE - STATIC
  • 51. CSS POSITION PROPERTY - RELATIVE - is used to position an HTML element in an HTML - document values: static, relative, absolute, fixed & sticky - position: relative; - is used to position an HTML element relative to its normal position - Note: while using position property; we take help of left, right, bottom, top and z-index properties to position an HTML element.
  • 52. CSS POSITION PROPERTY - RELATIVE
  • 53. CSS POSITION PROPERTY - ABSOLUTE - is used to position an HTML element in an HTML - document values: static, relative, absolute, fixed & sticky - position: absolute; - is used to position an HTML element relative to the edges of it's first positioned ancestor or relative to the edges of the browser’s viewport - Note: while using position property; we take help of left, right, bottom, top and z-index properties to position an HTML element.
  • 55. CSS POSITION PROPERTY - FIXED CSS position property: - is used to position an HTML element in a document values: static, relative, absolute, fixed & sticky position: fixed; - is used to position and pin (or fix) an HTML element relative to the edges of the browser’s viewport Note: while using position property; we take help of left, right, bottom, top and z-index properties to position an HTML element.
  • 57. CSS POSITION PROPERTY - STICKY - is used to position an HTML element in an HTML document - values: static, relative, absolute, fixed & sticky - position: sticky; - is used to position and stick an HTML element relative to top edge of the browser viewport - Note: while using position property; we take help of left, right, bottom, top and z-index properties to position an HTML element.
  • 59. CSS Z-INDEX PROPERTY - is used to position an HTML element in an HTML document - values: static, relative, absolute, fixed & sticky - W.K.T. while positioning HTML elements; we take help of left, right, bottom, top and z-index properties. - CSS z-index property: - is used to control the displaying order of overlapping positioned HTML elements - Note: - an HTML element with lower z-index value is displayed behind an HTML element with higher z-index value
  • 61. CSS DISPLAY PROPERTY When you create an element to display on the page, it renders as a box & we have seen how to position those boxes on the page, but there’s more we can do with them. CSS’s Display property specifies the type of rendering box that is created from our HTML. Let’s check out some of the different display styles we can use. BLOCK — Element starts on a new line & takes up the entire width. May contain other block or inline elements. Elements that are block-level by default include <div>, <p>, <h1>-<h6>, <ul>, <li>, & <canvas>. INLINE —Element can start anywhere on an existing line. Height and width properties have no effect. Elements that are inline by default include <span>, <input>, <button>, &<img>. GRID — Element is displayed block-level with inner content in grid layout. FLEX — Element is displayed block-level with inner content in flexbox layout. INLINE-BLOCK — Element is displayed inline but height and width may be defined. May also be used with grid, flex, or table as these are block-level elements. NONE — Removes this element & all children (to just make an item invisible but still take up space on the page use the visibility property)
  • 62. CSS FLEXBOX AND GRID LAYOUT PROPERTY
  • 63. CSS FLEXBOX LAYOUT PROPERTY
  • 64. CSS FLEXBOX LAYOUT PROPERTY Property #1: Display: Flex
  • 65. CSS FLEXBOX LAYOUT PROPERTY Property #1: Display: Flex
  • 66. CSS FLEXBOX LAYOUT PROPERTY Property #2: Flex Direction
  • 67. CSS FLEXBOX LAYOUT PROPERTY Property #2: Flex Direction
  • 68. CSS FLEXBOX LAYOUT PROPERTY Property #3: Justify Content
  • 69. CSS FLEXBOX LAYOUT PROPERTY Property #4: Align Items
  • 70. CSS FLEXBOX LAYOUT PROPERTY Property #4: Align Items
  • 71. CSS FLEXBOX LAYOUT PROPERTY Property #5: Align Self