码迷,mamicode.com
首页 > Web开发 > 详细

尝试规范css代码

时间:2016-06-04 14:45:38      阅读:136      评论:0      收藏:0      [点我收藏+]

标签:

1.模块分割,用如下的标注来提示你的css代码作用;
    /* -------------*/ /* ---------->>> GLOBAL <<<-----------*/ /* ----------*/

    A sample format I try to stick to is this:

    Global Styles – (body, paragraphs, lists, etc)
    Header
    Page Structure
    Headings
    Text Styles
    Navigation
    Forms
    Comments
    Extras

2.代码的统一管理

    例如:
        1).标题
                h2 { }

                    #snapshot_box h2 {
                        padding: 0 0 6px 0; }

                    #main_box h2 {
                        color: #e2e2e2; }

                     .sidetagselection h2 {
                        color: #fff;
                        font: bold 14px/14px “Verdana”, sans-serif; }
                        
     you’ll be able to style each one independently and not worry about child classes inheriting attributes from the parent class.
        
3.使用简写
        例如:margin: 0px 1px 0 0;
4.头部样式的使用的重要性;important;
    If you know that all of the h2’s will not have a margin or padding, define that on the top level and let its effect cascade as it is supposed to.

尝试规范css代码

标签:

原文地址:http://www.cnblogs.com/foxNike/p/5558675.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!