Css
Basic syntax
A CSS rule consists of two main parts: a selector, and one or more declarations.
selector {declaration1; declaration2; ... declarationn}
Selectors are usually HTML elements that you need to change the style.
Each declaration consists of an attribute and a value.
The property is the style property (style attribute) that you want to set. Each property has a value. Attributes and values are separated by colons.
selector {Property:value}
Common selectors
ID Selector--you can specify a specific style for an HTML element labeled with a specific ID, defined by "#"
#red {color:red;}
#green {color:green;}
ID selector and Derivation selector
In modern layouts, the ID selector is often used to create a derived selector
#sidebar p {
Font-style:italic;
Text-align:right;
Margin-top:0.5em;
}
Class Selector--displayed as a dot
. center {Text-align:center;}
Class can also be used as a derived selector:
. Fancy TD {
Color: #f60;
Background: #666;
}
The first character of the "note" class name cannot use a number! It doesn't work in Mozilla or Firefox.
Tag Selector (element selector)
This is the most common, in other words, the element of the document is the most basic selector.
If you set the HTML style, the selector will usually be an HTML element, such as p, H1, EM, a, or even the HTML itself:
HTML {color:black;}
h1 {Color:blue;}
h2 {Color:silver;}
Property Selector--style The HTML element with the specified property
<!--setting Styles--
[Title]
{
color:red;
}
<a title= "W3school" href= "http://w3school.com.cn" >W3School</a>
CSS settings background (background)
Background color Background-color
Background image Background-image
Repeat background-repeat:repeat-x/repeat-y background
Background position Background-position:bottom/left/top/right/center
Background correlation Background-attachment:fixed/scroll
General wording:
. Tagname{background: #ffffff url ("aa.jpg") No-repeat right left;}
CSS formatting text
With text properties, you can change the color of the text, the spacing of characters, the alignment text, the decoration, the indentation of the text, and so on.
Text indent: Text-indent:2em
Text alignment: Text-align:left/right/center/justify
Text decoration: Text-decoration:underline/line-through/overline/none
Character spacing: Word-spacing:px/em The spacing between English words;
Letter-spacing:px/em the spacing between Chinese characters and English letters;
Text conversion: Text-transform:uppercase/lowercase/capitalize
Row-to-row spacing: line-height:px/%
Vertical alignment of images: Vertical-align:text-top/text-bottom
Text shadow: Text-shadow: Horizontal offset, vertical offset color
Font
Font type: font-family: "Sans-serif";
Font style: Font-style:normal;
Font size: font-size:20px/3.75em/100%; default size is 16px, font is Arial
Font bold: Font-weight:normal;
The transformation of the font: font-variant:normal/smallcaps;
CSS Links
Four Status of links
a:link {color: #FF0000;}/* Links not visited */
a:visited {color: #00FF00;}/* The link has been visited */
a:hover {color: #FF00FF;}//mouse pointer moves to link */
a:active {color: #0000FF;}/* The link being clicked */
Note When you set styles for different states of a link, follow these order rules:
A:hover must be located after A:link and a:visited
A:active must be located after a:hover
Remove the default underline for a link
Text-decoration:{none/underline}
a:link {text-decoration:none;}
a:visited {text-decoration:none;}
a:hover {text-decoration:underline;}
a:active {text-decoration:underline;}
Create a link block
Display:block;
List Style
In an unordered list, the flag (marker) of a listing item is the dot that appears next to each list item. In an ordered list, a flag may be a symbol in letters, numbers, or some other counting system.
To modify the type of flags used for list items, you can use the attribute List-style-type:
UL {list-style-type:square;}
The above declaration sets the list item flags in the unordered table to squares.
List item Image
You may want to use an image for each flag, which can be done using the List-style-image property:
UL li {list-style-image:url (xxx.gif);}
1
List Flag Location
ul{
List-style-position:inside;
}
CSS Tables
Table border
table,th,td{border:1px solid Red;}
Collapse border
Border-collapse:collapse;
Width and height of table
Width,height
Horizontal alignment of text in a table
Text-align:center/right/left;
Vertical alignment of text in table
Vertical-align:bottom;
The inner margin of the table
Padding
Background color of the table
Background
CSS Basic syntax