css编写规范:如何合并组合类和嵌套类

css重构1:合并具有相同的属性的选择器
原内容:
h2 {
color: red;
}
.thisOtherClass {
color: red;
}
.yetAnotherClass {
color: red;
}

重构后:
h2, .thisOtherClass, .yetAnotherClass {
color: red;
}


css重构2:嵌套
网页结构如下:
<div id="top">
<h1>Chocolate curry</h1>
<p>This is my recipe for making curry purely with chocolate</p>
<p>Mmm mm mmmmm</p>
</div>
嵌套css如下:
#top {
background-color: #ccc;
padding: 1em
}
#top h1 {
color: #ff0;
}
#top p {
color: red;
font-weight: bold;
}
posted @ 2009-06-04 14:40  果果乐园  阅读(786)  评论(0编辑  收藏  举报