Typographic constraints of single-line style writing styles
1. Curly braces for each rule {before and after spaces
2. Multiple selector share a style set, multiple selector must be written in multiline form
3. A space before closing the curly brace} for each rule
4. Attribute name preceded by a colon without a space, followed by a space after the colon
5. A semicolon must be added after each attribute value; And the semicolon after the space
For example:
div.test {width:100px; height:200px;}
A:focus,
a:hover {position:relative; right:1px;}
The typographic constraints of the multi-line form writing style
1. The curly brace of each rule {before adding a space
2. Multiple selector share a style set, multiple selector must be written in multiline form
3. The curly brace at the end of each rule must be aligned with the first character of the rule selector
4. Attribute name preceded by a colon without a space, followed by a space after the colon
5. Add a semicolon after the attribute value;
Other specifications
1. Use single quotation marks, no double quotes allowed
2. If the CSS3 attribute is used, add the browser prefix, if necessary, in the order of webkit-/-moz-/-ms-/-o-/STD, the standard attribute is written at the end, and the property name is aligned, for example:
Div.animation-demo {
-webkit-animation:mymove 5s Infinite;
-moz-animation:mymove 5s Infinite;
-o-animation:mymove 5s Infinite;
Animation:mymove 5s Infinite;
}
Naming rules writing specifications
1, the rule naming, all use lowercase and underline the way, do not allow the use of capital letters or _
2, the name to avoid the use of Chinese pinyin, should adopt a more concise and semantic English words to combine
3, naming attention abbreviations, but not blindly abbreviated, see commonly used CSS naming rules
4, not allowed by the 1, 2, 3 and other serial number named
5. Avoid class and ID names
6, ID is used to identify a module or a page of a parent container area, the name must be unique, do not feel free to create new ID
7. Class is used to identify an object of a certain type, and the name must be concise.
8, as far as possible to improve the code module reuse, style as far as possible in a combination of ways
9, the rule name should not contain color (red/blue), positioning (left/right) and other information related to the specific display effect. It should be named with meaning rather than the style display result.
10. In addition to resetting the default browser style, you are prohibited from adding CSS style settings directly to the HTML tag, for example:
div {
width:200px;
font-size:16px;
}
11. Each rule should ensure that selectors are unique and prohibit direct global. Nav/.header/.body Class Setting properties
Attribute Authoring Order
Recommended order of Style writing
1. Display Properties
Display/list-style/position/float/clear
2. Self-attributes (box model)
Width/height/margin/padding/border
3. Background
Background
4, Row high
Line-height
5. Text Properties
color/font/text-decoration/text-align/
Text-indent/vertical-align/white-space/content
6. Other
Cursor/z-index/zoom
7. CSS3 Properties
Transform/transition/animation/box-shadow/border-radius
8, the link style please strictly follow the following order to add:
A:link, a:visited, A:hover, a:active (lovehate)
Performance optimization
1. Selectors should be as short as possible on the basis of satisfying function, reduce the nesting of selectors, and query consumption. But be sure to avoid overriding global style settings.
2. Note the performance of the selector and do not use a low-performance selector, such as:
div > * {}
UL > li > a {}
Body.profile Ul.tabs.nav li a {}
3. Disable the use of the * selector in CSS
4. Unless necessary, otherwise, there is usually a class or ID, do not need to write the tag corresponding to the element, for example:
div#test {width:100px;}
5.0 does not need units, such as 0px can be omitted into 0,0.8px can be omitted. 8px
6. If the color is 16 binary, the color value should be capitalized.
7. If possible, color as far as possible with three-bit characters, such as #aabbcc written #abc
8. If there is no border, do not write border:0, should be written Border:none
9. Try to avoid using AlphaImageLoader
10. Try to merge duplicate styles as much as possible while keeping the code decoupled
background, font, etc. can be abbreviated attributes, try to use abbreviated form
Hack
IE6 * HTML Selector {...}
IE7 *+html Selector {...}
Non-IE6 html>body selector {...}
Firefox @-moz-document Url-prefix () {...}
Safari3+/chrome @media screen and (-webkit-min-device-pixel-ratio:0) {...}
Opera @media all and (-webkit-min-device-pixel-ratio:10000), not all and (-webkit-min-device-pixel-ratio:0) {...}
Iphone/mobile WebKit @media screen and (max-device-width:480px) {...}
Z-index Criteria for value collection
|
Head Navigation Area |
[1999-2100] |
|
Publisher's content head area |
[1998] |
|
Page Main content Area |
[-1-1997] |
|
Bottom of page |
[1999-2100] |
|
Home Application shell Layer |
[1000] |
|
All-Station public components |
[-1-1999] |
|
Full Page Masking popup component |
[10000-11000] |
Other
1, the font name should be mapped to the corresponding English name, for example: Bold (Simhei) Arial (SimSun) Microsoft Jache (Microsoft Yahei), if the font name has spaces, you must add single quotation marks.
2, the background picture please use csssprites reasonably, according to module, business, page to divide can
3, CSS background image file type, please follow the following principles to save:
3.1 If the background picture is animated, save it as a GIF
3.2 If there is no animation, there is no translucent effect, then save to Png-8
3.3 If you have a translucent effect, save it as png-24
4. Do not add tags to the HTML to clean up the float, by adding the. Clearfix to the floating element's parent element. Clear Float
5, for SEO and page usability, please use text-indent to hide the text content.
6, when making CSS sprites, try to put the color similar icons together, stored as PNG8 format, after storage can also use some compression tools for lossless compression.
7, avoid too small background image tiling.
8, try to use less!important
9. Avoid using non-disposable expression
Go CSS Coding Specification