由于样式名称重复,是否有一种全局方法可以从 div 中清除 CSS 样式?我们正在合并内容,并试图通过使用多个样式表来最小化工作。这是我一直在做的一个测试:http: //jsfiddle.net/Codewalker/yU2sW/7/。但是,由于它是 JSFiddle,我没有引用两个外部样式表,而是将它们组合在 CSS 窗口中。注意 secondary_container div 如何从另一个容器继承蓝色文本。我还粘贴了下面的代码:
<div class="container">
<h1>This is in an h1 tag.</h1>
<p>This is at the very top, outside the secondary_container stuff. All kinds of content can go down here. All of this is within a paragraph tag. I'll write one more sentence then copy all this over again. Sound good? Wait that's two more sentences. Actually four. Oh well. So much for that. Here goes a little copying and pasting. All kinds of content can go down here. All of this is within a paragraph tag. I'll write one more sentence then copy all this over again. Sound good? Wait that's two more sentences. Actually four. Oh well. So much for that. Here goes a little copying and pasting.</p>
<div id="secondary_container">
<div class="container">
<p>This is within the container div that's within the secondery_container div. All kinds of content can go down here. All of this is within a paragraph tag. I'll write one more sentence then copy all this over again. Sound good? Wait that's two more sentences. Actually four. Oh well. So much for that. Here goes a little copying and pasting. All kinds of content can go down here. All of this is within a paragraph tag. I'll write one more sentence then copy all this over again. Sound good? Wait that's two more sentences. Actually four. Oh well. So much for that. Here goes a little copying and pasting.</p>
</div>
</div>
</div>
这是 CSS,它实际上是两个独立的外部样式表:
/* BEGINNING OF FIRST CSS FILE styler.css */
.container {
background-color: #00FF00;
height: auto;
width:960px;
margin: 0 auto;
line-height: 20px;
}
h1 { font-family:Arial, Helvetica, sans-serif; font-size:14px; color: #F00; text-transform:uppercase; }
p { font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#00F;
}
/* BEGINNING OF SECOND CSS FILE secondary_container.css
*/
#secondary_container .container h1 { font-family:Georgia, "Times New Roman", Times, serif; color: #0F0; }
#secondary_container .container p { font-style:italic; line-height:14px;}