CSS----Cascading Style sheets cascading style Sheet
First, the classification of CSS
1. External style sheet---. CSS file
2. Embedded style sheet---placed in
3. Inline style sheet---attributes placed on the marker style
Second, selector
(i) Basic selector
1.id selector: #
2.class selector:.
3. Tag Selector: Tag name, example body{}
(ii) Combination Selector
1. Separate by commas. Tie relationship html,body, #dd, #s {}
2. Separated by a space. Descendant relationships. SS a{}. SS. aa{}
3. Filter. Selector. class Selector Input.tt (filter input, find CLASS=TT input)
Input. TT (all elements that are placed in input class=tt)
The meaning of the cascade:
1. Cascading of Style sheet types
2. Cascade of Selectors
3. Cascade of Parent-child elements
Priority level:
1. In general, the priority of the ID selector is higher than the class selector priority, and the class selector takes precedence over the label selector.
2. For selectors of the same type, inline styles are higher than inline, with inline styles having precedence over external.
Iii. properties of a style sheet
(i) Prospects and background
1. Background: background-color: Background color
Background-image:url (path) Background map
background-attachment:fixed---Background fixed, scroll---background with text scrolling
Background-repeat:repeat----tiled, no-repeat---uneven, repreat-x---horizontally tiled, repeat-y---vertically tiled
Background-position:right 100px Bottom 200px; Left top; Center ..... (Repeat must be no-repeat when setting the background map)
2. Foreground: font-family:
Font-size:
Color
Font-weight:bold;
Font-style:italic;
Text-decoration:underline,none,overline (underline), Line-through (strikethrough);
Text-align:left,center,right.
Vertical-align:middle,top,bottom.
Line-height: Row height. It is generally 1.5--2 times of font-size.
(ii) Borders and borders
1. Border (two-bit interface)
| Boder |
Style |
Color |
Width |
| Top |
Border-top-style |
Border-top-color |
Border-top-width |
| Right |
Border-right-style |
Border-right-color |
Border-right-width |
| Bottom |
Border-bottom-style |
Border-bottom-color |
Border-bottom-width |
| Left |
Border-left-style |
Border-left-color |
Border-left-width |
2. Margin Padding:top right bottom left
3. Inner margin margin:top right bottom left
(iii) lists and blocks
Blocks: width, heiht, top, left ...
List (<ul><li></li></ul>):
List-style-type:
List-style-position:outside,inside.
List-style-image:url (PATH)
Display:none---does not show, block---block display (exclusive row), inline---not exclusive row (Width,height no matter), Inline-block---not exclusive line (Width,height)
Visibility: is visible. Visible---can be seen, hidden---hidden. If it is hidden, the position is still occupied.
Overflow: overflow handling. Hidden---Hide the out-of-section, scroll---Out of the display scroll bar.
(iv) format and layout
Location layout
Position: (fixed,absolute,relative)
Style properties for mates: Top,right,bottom,left ....
Fixed----absolute positioning. The browser visible area is positioned as the coordinate system, not the page coordinates. Usually used to make a floating layer, IE6 not. Example: Lower right corner of the ad small window, pop-up window ....
Relative---relative positioning. The relative meaning is relative to the position where the element was supposed to be. Although the position of the element is changed, the original space is still occupied.
Absolute----absolute positioning. If an element outside the element does not have a absolute style set, it is positioned as a coordinate system throughout the page.
Example: <style type= "Text/css" >
#d1 {...}
#d2 {... position:absolute;top:100px;left:100px;}
</style>
<body>
<div id= "D1" >
<div id= "D2" ></div>
</div>
</body>
If there is an element outside this element that has the position style attribute, then he is positioned with this peripheral element as the coordinate.
Example: <style type= "Text/css" >
#d1 {...; Position:absolute;}
#d2 {... position:absolute;top:100px;left:100px;}
</style>
<body>
<div id= "D1" >
<div id= "D2" ></div>
</div>
</body>
Flow layout
Float
Style properties for mates: Margin,margin-top,margin-right,margin-bottom,margin-left;
Clear: Clear float. Clear:both
Example:
Example one, several parallel layers use the law of float layout. (Note to remove floating)
<style type= "Text/css" >
. b
{
width:200px;
height:200px;
border: #F00 5px solid;
}
#d1, #d2
{
width:150px;
height:150px;
border: #00F 5px solid;
Float:left;
}
</style>
<body>
<div id= "D1" class= "B" >
</div>
<div id= "D2" class= "B" >
</div>
<div id= "D3" class= "B" >
</div>
<div id= "D4" class= "B" >
</div>
</body>
If the following two red boxes do not float up, use Clear:both to remove the float.
<body>
<div id= "D1" class= "B" >
</div>
<div id= "D2" class= "B" >
</div>
<div style= "Clear:both" ></div>
<div id= "D3" class= "B" >
</div>
<div id= "D4" class= "B" >
</div>
</body>
Example two, nested layer, using the law of float layout. (float on both inner and outer layers)
<style type= "Text/css" >
#d1
{
Background-color: #00F;
width:100%;
Float:left;
}
#d2
{
width:200px;
height:200px;
Background-color: #F00;
Float:left;
}
</style>
<body>
<div id= "D1" >
<div id= "D2" ></div>
</div>
</body>
CSS Naming conventions:
Usually we most commonly use the main name: Wrap (jacket, outermost), header (header, head), NAV (navigation bar), menu, title (column headings, general mates H1\h2\h3\h4 tags)
, Content (contents area), footer (footer, bottom), logo (logo, can be used with H1 tags), banner (banner, general at the top), copyright.
Main
Hotspot: Hot
Press: News
Download: Download
Sub-navigation: Subnav
Menus: Menu
Sub-menu: submenu
Searches: Search
Links: Friendlink
Footer: Footer
Copyrights: Copyright
Scrolling: Scroll
Contents: Content
Tabs page: Tab
Article List: List
Hint Message: MSG
Tip: Tips
Column Title: Title
Join: Joinus
Guide: Guild
Services: Service
Registration: Regsiter
State: Status
Vote: Vote
PARTNER: Partner
(b) The wording of the note:
/* Footer */
Content Area
/* End Footer */
(c) The name of the ID:
(1) Page structure
Container: Container
Page Header: Header
Content: Content/container
Page body: Main
Page End: Footer
Navigation: Nav
Sidebar: Sidebar
Column: Column
Page perimeter control overall layout width: Wrapper
Middle: Left Right center
(2) Navigation
Navigation: Nav
Main navigation: MAINBAV
Sub-navigation: Subnav
Top Navigation: Topnav
Side navigation: Sidebar
Left navigation: Leftsidebar
Right navigation: Rightsidebar
Menus: Menu
Sub-menu: submenu
Caption: Title
Abstract: Summary
(3) function
Logo: Logo
Ad: Banner
Login: Login
Login Strip: Loginbar
Registration: Regsiter
Searches: Search
Functional area: Shop
Caption: Title
Join: Joinus
State: Status
Button: BTN
Scrolling: Scroll
Tabs page: Tab
Article List: List
Hint Message: MSG
Present: Current
Tip: Tips
Icons: Icon
Note: note
Guide: Guild
Services: Service
Hotspot: Hot
Press: News
Download: Download
Vote: Vote
PARTNER: Partner
Links: Link
Copyrights: Copyright
(d) Name of class:
(1) Color: Use the name of the color or the 16 code, as shown in
. red {color:red;}
. F60 {color: #f60;}
. ff8600 {color: #ff8600;}
(2) Font size, directly using "font+ font size" as the name, as
. font12px {font-size:12px;}
. font9pt {font-size:9pt;}
(3) Alignment style, using the English name of the alignment target, such as
. left {float:left;}
. bottom {float:bottom;}
(4) title bar style, named using "Category + function", as
. Barnews {}
. barproduct {}
Precautions::
1. Lowercase;
2. Try to use English;
3. Do not add the middle bar and underline;
4. Try not to abbreviate unless you see the words clearly.
The main master.css
Module MODULE.CSS
Basic shared Base.css
Layout, Layout layout.css
Theme Themes.css
Column Columns.css
Text Font.css
Form Forms.css
Patch Mend.css
Print Print.css
CSS content Concatenation