我有两个单独的 HTML 页面:
<!-- in the body of page1.html -->
<div class="foo">
<!-- content goes here -->
</div>
和:
<!-- in the body of page2.html -->
<div id="bar">
<!-- some other content goes here -->
</div>
目前我使用一些常见的 CSS 定位这些 div 元素:
.foo {
width: 680px !important;
}
#bar {
margin: auto;
width: 680px !important;
}
是否有更短的(DRY - 不要重复你自己)方法来做到这一点?
最佳答案
你可以这样试试:
.foo, #bar {
width: 680px !important;
}
关于html - 同时定位一个 id 和一个类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43722746/