采用以下 HTML:
<div id="topbar">
<div class="sitewidth"></div>
</div>
<div class="sitewidth"></div>
<div id="content" class="sitewidth front-page">
</div>
如何定位第二个 sitewidth
,而不会对 topbar
中的 sitewidth
和下一个 div 中的 sitewidth
触发相同的效果?
请注意,我无法访问 HTML,我只能使用 CSS!
最佳答案
基于此评论
sitewidth is used on multiple places, also right after this one again. It is, however, the 2nd time it gets used and I think that's how it always is (in other words: as far as I know, nothing gets in between topbar and the second sitewidth
和这个结构
<div id="topbar">
<div class="sitewidth"></div>
</div>
<div class="sitewidth"></div>
然后
#topbar + .sitewidth {
your styles here
}
这只会针对 sitewidth
div,它紧跟 #topbar
,而不是其他。。
关于html - 将 DIV 定位在一个地方,然后在多个地方使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27404262/