好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

CSSReset_html/css_WEB-ITnose

有一个专门讲CSS Reset的站点。 site

由于各大浏览器的user agent样式(即默认样式)不同,为了尽可能避免浏览器之间样式的差异,重置了css样式,让浏览器之间可以由一个基本相同的样式基准,并在该基准的基础上进行开发。

引入CSS Reset样式

引入CSS Reset,意味着告诉浏览器将所有元素应用上reset的样式,再使用针对页面或业务的特定样式。对于页面加载而言,这不算一个最优的方式,但对于组织css代码而言是一个好方法,因为页面针对不同浏览器都在一个统一的基准上开发。

而通常来说CSS Reset网上有许多现成的(可以去上面的链接里找),但直接引入或者直接复制黏贴不是推荐的做法,这里我直接引用:

The reset styles given here are intentionally very generic. I don’t particularly recommend that you just use this in its unaltered state in your own projects. It should be tweaked, edited, extended, and otherwise tuned to match your specific reset baseline. Fill in your preferred colors for the page, links, and so on.
In other words, this is a starting point, not a self-contained black box of no-touchiness.

简单地说,引入bootstrap后,即使html中没有定义任何class或者inline style,依然可以呈现出优雅的页面,即推荐大家根据自己的需求定制自己的CSS Reset,而不是直接拷贝(虽然确实省事)。

CSS设计

在为一个站点写css样式时,我认为可以分为三层:全局层,模块层,页面逻辑层。

全局层代表的是应用在所有页面上样式,模块层值的是应用在各个具有相同样式规则的元素上的,页面逻辑层是每个页面都不共享的一些特殊样式。而CSS Reset则可以作为全局层的一部分让所有页面具有相同的样式基准,对于模块层和页面逻辑层,举个例子:

             Document          /*全局层*/    * { margin: 0px; padding: 0px; }    /*模块层*/    .list {        margin-left: -10px;        margin-right: -10px;        font-size: 16px;        width: 100%;    }    .list .list-item {        padding-left: 10px;        padding-right: 10px;        float: left;        background: #ccc;    }    .list:after, .clearfix:after {        content: "";        display: table;        clear: both;    }    /*页面逻辑层*/    .testlist {        color: #3c3c3c;    }           

a

查看更多关于CSSReset_html/css_WEB-ITnose的详细内容...

  阅读:32次