嘿,这听起来可能是个彻底的问题,但我从来没有真正学会如何做到这一点。我有一堆这样的证件:
#f1 {
a lot of styles!
order: 1;
}
#f2 {
a lot of styles!
order: 2;
}我的意思是我复制/粘贴了40次。有没有办法巩固“很多风格!”只需为每个ids编写不同的订单就行了?
谢谢你的帮助!-)
发布于 2013-11-10 09:19:13
你可以为你的“很多风格”使用一个通用的选择器:
#f1, #f2 {
a lot of styles!
}
#f1 { order: 1; }
#f2 { order: 2; }减少第一个选择器的一个适当的替代方法是为每个元素分配一个类,例如.common并用.common替换#f1, #f2, ...。
更多信息:CSS元素,元素选择器
发布于 2013-11-10 09:21:55
使用class和id的
示例
CSS
.className {
// common style that they all share
}
#f1 {
// distinct styles only this id will use
}
#f2 {
// distinct styles only this id will use
}HTML
<div class="className" id="f1">
</div>
<div class="className" id="f2">
</div>https://stackoverflow.com/questions/19888076
复制相似问题