when writing code, having a good specification and order can save you a lot of time. some methods of the relevant CSS writing order and specification are recommended below. This document will be sorted into the front-end specification document, if you have a better opinion, may wish to inform us in a message.
CSS Writing Order
The code comes from the Internet, which initially appears to be on Mozilla's website.
1. Display & Flow (show and stream) 2. Positioning (position) 3. Dimensions (size) 4. Padding, Borders,margins,outline (padding, boundary, Edge, contour) 5. Typographic styles (layout style) 6. Backgrounds (background) 7. Opacity, Cursors, Generated content (opacity, cursor, generated contents)
Example:
El {display:; Visibility:; float:; Clear:;p osition:; top:; right:; bottom:; Left:; Z-index:; width:; Min-width:; Max-widt H:; height:; Min-height:; Max-height:; overflow:;p adding:;p adding-top:;p adding-right:;p adding-bottom:;p adding-left :; border:; Border-top:; Border-right:; Border-bottom:; Border-left:; Border-width:; Border-top-width:; Border-right-width: border-bottom-width:; Border-left-width:; Border-style:; Border-top-style:; Border-right-style :; Border-bottom-style:; Border-left-style:; Border-color:; Border-top-color:; Border-right-color:; Border-bottom-color: Border-left-color:; margin:; Margin-top:; Margin-right:; Margin-bottom:; Margin-left:; Outline: ; List-style: table-layout:; Caption-side:; Border-collapse:; border-spacing:; Empty-cells:; font:; font-family:; Font-size: line-height:; Font-weight:; Text-align:; Text-indent:; Text-transform:; Text-decoration:; Letter-spacing: ; word-spacing:; White-space:; vertical-align:; color:; background:; Background-color:; BACKground-image: background-repeat:; background-position:; opacity:; cursor:; content:; quotes:;}
CSS Writing specifications
Using CSS abbreviation properties
CSS Some properties can be abbreviated, such as Padding,margin,font, and so on, so that the refinement of the code at the same time can improve the user's reading experience.
Abbreviated name
Many users like abbreviated class name, but the premise is to let people understand your name to shorthand Oh!
16 Binary color code abbreviations
Some color code can be abbreviated, we try to abbreviate it, improve the user experience mainly.
Hyphen CSS Selector naming specification
1. Long name or phrase you can use the middle horizontal line to name the selector.
2. It is not recommended to use the "_" Underline to name the CSS selector, why?
- Press the SHIFT key less when typing;
- Browser compatibility issues (such as naming using _tips selectors, which are not valid in IE6)
- Good to distinguish JavaScript variable name (JS variable name is "_")
Here is a detailed discussion of dashes and underscores, in English: Click to view the Chinese text: Click to view
Don't feel free to use ID
ID in JS is unique, can not be used multiple times, and the use of class selector is reusable, and the priority of the ID priority and class, so the ID should be used on demand, and can not be abused.
Add a status prefix to the selector
Sometimes you can add a prefix to the selector to indicate the status, so that the semantics are clearer, such as adding the ". is-" prefix.
Common CSS Naming conventions
Head: Header
Content: Content/container
Tail: Footer
Navigation: Nav
Sidebar: Sidebar
Column: Column
Page perimeter control overall layout width: Wrapper
Middle: Left Right center
Login Strip: Loginbar
Logo: Logo
Ad: Banner
Page body: 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
Tags: tags
Article List: List
Hint Message: MSG
Tip: Tips
Column Title: Title
Join: Joinus
Guide: Guides
Services: Service
Registration: Regsiter
State: Status
Vote: Vote
PARTNER: Partner
notation:
/* Header */
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: Mainnav
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: Register
Searches: Search
Functional area: Shop
Caption: Title
Join: Joinus
State: Status
Button: BTN
Scrolling: Scroll
Tags 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
Precautions::
1. Lowercase;
2. Try to use English;
3. Do not add the lever and underline;
4. Try not to abbreviate unless you see the words clearly.
CSS style sheet file naming
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 writing order and common naming recommendations