One, selector
CSS rules consist of selectors and declarations.
/*Selector Grouping*/H1, H2, H3{}/*descendant Selector*/p em{}/*child element Selector*/p > Em{}/*Brother Selector (select the element that has the same parent element after it)*/h3 + P{}/*ID Selector*/#id{}/*class Selector*/. Class{}/*Property Selector*/[attr]{}View Code
The property selector is used.
| [attr] |
Select an element with Val |
| [Attr=val] |
Select an element with a Val attribute |
| [Attr~=val] |
Select the element that contains Val in the attribute |
| [Attr|=val] |
Select an element whose attributes begin with val- |
| [Attr^=val] |
element that matches the attribute starting with Val |
| [Attr$=val] |
Elements that match attributes to end with Val |
| [Attr*=val] |
The match attribute contains the elements of Val |
Two, style
/*background*/Body{Background-color:LightBlue;Background-image:URL ("wallpaper.jpg");background-repeat:no-repeat;background-position:Center;background-attachment:fixed;/*Prevent background scrolling with document scrolling*/}/*text*/P{text-indent:5%;/*Indent in*/text-align:Justify-all;/*Horizontal Alignment*/word-spacing:Normal;/*Word interval*/letter-spacing:Normal;/*Letter Spacing*/Text-transform:Capitalize;/*character conversion (capitalize the first letter of the word)*/text-decoration:Underline;/*Text Decoration*/}/*Font*/Body{font-family:"MS Reference Sans Serif", monospace;Font-style:Italic;font-variant:Small-caps;/*Small Capital letters*/Font-weight:Bold;/*Font Bold*/}/*links that have not been visited*/A:link{Color:#FF0000;}/*links that have been visited*/a:visited{Color:#00FF00;}/*Hover Link*/a:hover{Color:#FF00FF;}/*Click the link*/a:active{Color:#0000FF;}/*List*/ul{List-style-image:URL ("Icon.png");/*List item Image*/List-style-type:Circle;/*List Item Flags*/list-style-position:inside;}/*Table*/table, TH, TD{Border-width:1px;Border-style:Solid;Border-color:LightBlue;Border-collapse:collapse;/*collapse Border*/text-align: Left;/*alignment of table text*/Padding-left:Auto;/*left margin in table*/Background-color:LightGreen;}/*Contour*/Table{Outline-color:Lightpink;Outline-style:dotted;Outline-width:Thick;}View Code
Three, Box model
The box model specifies how the element frame handles the inner margins, margins, borders, and contents of an element.
{ padding: 10%/* internal margin */ margin: 10%/* outer margin */}
View Code
Four, positioning
Positioning training defines where the element box should appear relative to its normal position, or relative to the parent element or even the location of the browser window. CSS consists of three basic positioning mechanisms: normal flow, floating, and absolute positioning. Unless specified, all boxes are positioned in the normal stream, and the position of the elements in the normal stream is determined by the order in which they appear in the HTML document.
- Relative positioning: The element box is offset by a distance. The element still retains its shape before it is positioned.
- Absolute positioning: The element box is completely removed from the document flow, relative to the block that contains it.
- Floating: The floating box is not in a normal stream and can be moved left or right until it touches the containing box or other floating box.
/*relative positioning*/#information{position:relative; Left:10%; Right:10%;}/*Absolute Positioning*/#information{position:Absolute; Left:10%; Right:10%;}/*Floating*/#information{float: Right;}View Code
CSS notes: Basic tutorials