【发布时间】:2014-08-23 05:40:42
【问题描述】:
我希望这个 css 代码工作:
#inventoryGarbageSpot .id1,.id2,id3,id4{
padding:0px;
padding-top: 0px;
width:35px;}
如果我写一个 id 而不是多个 id 就可以了。
感谢您的帮助,
罗特姆
【问题讨论】:
我希望这个 css 代码工作:
#inventoryGarbageSpot .id1,.id2,id3,id4{
padding:0px;
padding-top: 0px;
width:35px;}
如果我写一个 id 而不是多个 id 就可以了。
感谢您的帮助,
罗特姆
【问题讨论】:
像这样使用attribute selector
风格是
#inventoryGarbageSpot [class^="id"]{
padding:0px;
padding-top: 0px;
width:35px;
}
应该是这样的
[class^="id"]{
// here style
}
【讨论】:
如果我们分解您的选择器,您的目标是:
#inventoryGarbageSpot .id1.id2id3id4首先,有 2 个不存在的元素:id3 和 id4,它们将代表这种元素:
<id3></id3>
<id4></id4>
其次,你需要在每节课前重复你的#inventoryGarbageSpot。
不要使用这个无效的选择器,而是使用这个:
#inventoryGarbageSpot .id1,
#inventoryGarbageSpot .id2,
#inventoryGarbageSpot .id3,
#inventoryGarbageSpot .id4 {
padding:0px;
padding-top: 0px;
width:35px;
}
如果您想泛化您的选择器,您可以使用属性选择器,如 Sudharsan 所述。
【讨论】: