[英]Styling multiple items CSS one tag
I have a table with a bunch of items, say 20. Every other row has a specific background color and the items in the cell do as well. 我的桌子上有一堆物品,比如20。每隔一行都有特定的背景颜色,单元格中的物品也是如此。
I achieve this with the following piece of CSS: 我通过以下CSS实现了这一点:
#item_list tr:nth-child(even),
#item_list tr:nth-child(even) input[type="text"],
#item_list tr:nth-child(even) input[type="number"] {
background-color: #d4d4d4;
}
My question is whether there is a neater way to end up with the same styling? 我的问题是,是否有一种更整洁的方式来结束相同的样式? Specifically without the repetition of
特别是没有重复
#item_list tr:nth-child(even)
or not? 或不?
Not using CSS. 不使用CSS。
If you use a pre-processor such as SASS or LESS then you could get syntax like: 如果使用预处理器(例如SASS或LESS),则可以得到如下语法:
#item_list tr:nth-child(even) {
background-color: #d4d4d4;
input[type="text"],
input[type="number"] {
background-color: #d4d4d4;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.