CSS 3
CSS 3
advantages of CSS :
- Easy maintainance
but simply all the html attributes are converted into css
properties.
CSS selectors :
5. grouping selector : it selects all html elements with the same style
definitions.
ways to insert CSS : 1. Inline CSS - by using style attribute in the relevant
tag.
2. Internal CSS - by using <style> tag in the head section.
- A block-level element always starts on a new line and takes up the full width
available.
- The <div> element is a block-level element.
- An inline element does not start on a new line and only takes up as much width as
necessary.
background properties :
background-image : url("image.jpg");
background-repeat : no-repeat;
vertically, background-repeat :
repeat-y;
horizontally, background-repeat :
repeat-x;
3. background-position : to control the position of an
image in background.
background-attachment : fixed;
color types :
hex codes :
RGB values :
text management :
color: red;
color: #0000FF;
color: rgb(0,255,255);
direction: rtl;
letter-spacing: 5px;
word-spacing: 5px;
text-indent: 1cm;
text-align: right,center,left ;
text-decoration : none;
text-transform : capitalize;
font management:
font-family : 'Time-new-roman':
font-style : italic;
font-variant : small-caps;
font-weight : bold;
font-weight : bolder;
font-weight : 900;
font-size : 20px;
font-size : small;
font-size : large;
font-size-adjust : 0.61;
font-stretch : ultra-expanded;
managing hyperlinks :
a : link{color: #000000}
a : visited{color: #006600}
a : hover{color:#FFCC00}
a : active{color:#FF00CC}
managing lists :
designing tables :
border-collapse : seperate;
caption-side : top,bottom;
empty-cells : hide;
border management :
border-bottom-color
border-top-color
border-right-color
border-left-color
border-left-style, border-right-style
outline management :
smallest unit - px
When the size of parent element changes, the size of the child changes
automatically.
Note: When em units are used on font-size property, the size is relative to
the font-size of its parent.
Here, only the first declaration takes the reference of the parent.
rem Unit: The rem is based upon the font-size value of the root element,
which is the <html> element.
it works outside the object. margin value ( px, %), ( w.r.t browser )
margin{ 10px 2% } --> top & bottom = 10px & 10px ( 2 - top
& bot, R & L )
margin {10px 2% -10px } --> top = 10px, left & right = 2%, bottom =
-10px ( 3 - top, L & R, bot )
margin {10px 2% -10px auto } --> top = 10px, right = 2%, bottom = -10px,
left = auto ( 4 - top, R, bot, L )
space should appear between the content of an element & its border.
it is not possible to use -ve values.
padding {10px 2% 20px } --> top = 10px, left & right = 2%, bottom =
20px ( 3 - top, L & R, bot )
padding {10px 2% 20px auto } --> top = 10px, right = 2%, bottom = 20px,
left = auto ( 4 - top, R, bot, L )
Content - The content of the box, where text and images appear.
The box model allows us to add a border around elements, and to define space
between elements.
-------------------------------
div {
width: 320px;
padding: 10px;
border: 5px solid gray;
margin: 0;
}
-------------------------------
320px (width)
Total element width = width + left padding + right padding + left border + right
border + left margin + right margin
The total height of an element should be calculated like this:
Total element height = height + top padding + bottom padding + top border + bottom
border + top margin + bottom margin
display :block;
display : inline;
display : list-item;
display : flex;
scale : increase or decrease the size of element. (to multiply width &
height)
translate : we can change the position X and Y axis. (we use pixels also)
nowrap : Default value. Specifies that the flexible items will not
wrap
positions: we can use two values top and left along with the position property to
move an HTML element anywhere in an HTML document.
NOTE: You can use the bottom or right values as well in the same way as top and
left.
.center{
margin: auto;
width: 50%;
border: 3px solid green;
padding: 10px;
}
Note: Center aligning has no effect if the width property is not set (or set
to 100%).
Example:
.center{
text-align: center;
border: 3px solid green;
}
Center an Image :
To center an image, use margin: auto; and make it into a block element.
img{
display: block;
margin: auto;
width: 40%;
}
Example:
.right{
position: absolute;
right: 0px;
width: 300px;
border: 3px solid #73AD21;
padding: 10px;
}
Note: Absolute positioned elements are removed from the normal flow, and can
overlap elements.
- When aligning elements with position, always define margin and padding for
the <body> element.
- Style visited and unvisited links differently Style an element when it gets
focus.
grid :
properties of grid :