【发布时间】:2013-05-22 02:12:00
【问题描述】:
有没有可能用 CSS 做这样的事情:
CSS:
#right div.item-page, #right .newsflashlatest_news {
padding: 0 133px 0 50px;
text-align: justify;
}
#right .item-page h1, #right .newsflashlatest_news h1 {
padding: 0 !important;
}
#right {
float: left;
width: 755px;
}
HTML:
<div id="right">
fsfds
<div class="item-page" style="background: blue;">
<h1>Home</h1>
<p>Pri iisque malorum ei, est te suavitate mediocritatem, facer molestie explicari vix ne. </p>
</div>
</div>
我需要将上述规则应用于 div.item-page 中除 h1 元素之外的所有元素。基本上这意味着除了 h1 元素之外的所有元素都会有填充。
简单地添加“#right div.item-page h1”对我的情况不起作用(见这里:http://jsfiddle.net/Pr47M/)
【问题讨论】:
-
试试
#right div.item-page :not(h1){}。 -
这也会为所有 div.item-page 级别的子元素添加填充(就像 div.item-page div div 也会收到填充,我不需要这个)
标签: css