Css 如何指定多个可以匹配给定选择器的类?
我正在尝试在我的CSS(wink)中进行干练练习,我被困在如何解决这个问题上 我如何减少这种情况:Css 如何指定多个可以匹配给定选择器的类?,css,css-selectors,Css,Css Selectors,我正在尝试在我的CSS(wink)中进行干练练习,我被困在如何解决这个问题上 我如何减少这种情况: table.shipmentItemList TD.title, table.shipmentItemList TD.author, table.shipmentItemList TD.options { font-size: 1.0em; font-weight: normal; } 对这样的事情: table.shipmentItemList TD.title, TD.aut
table.shipmentItemList TD.title,
table.shipmentItemList TD.author,
table.shipmentItemList TD.options {
font-size: 1.0em;
font-weight: normal;
}
对这样的事情:
table.shipmentItemList TD.title, TD.author, TD.options {
font-size: 1.0em;
font-weight: normal;
}
table.shipmentItemList {
td {
&.title, &.author, &.options {
font-size: 1.0em;
font-weight: normal;
}
}
}
table.shipmentItemList{
TD.title, TD.author, TD.options {
font-size: 1.0em;
font-weight: normal;
}
}
或者更好的是:
table.shipmentItemList TD .title, .author, .options {
font-size: 1.0em;
font-weight: normal;
}
我认为在这种情况下,您只能使用SASS: 标准CSS不允许您尝试做的事情。看看,或者您更愿意在服务器上做。你所问的问题在香草CSS中是不可能的 您的示例如下所示:
table.shipmentItemList TD.title, TD.author, TD.options {
font-size: 1.0em;
font-weight: normal;
}
table.shipmentItemList {
td {
&.title, &.author, &.options {
font-size: 1.0em;
font-weight: normal;
}
}
}
table.shipmentItemList{
TD.title, TD.author, TD.options {
font-size: 1.0em;
font-weight: normal;
}
}
看看less.js,它可以让您执行以下操作:
table.shipmentItemList TD.title, TD.author, TD.options {
font-size: 1.0em;
font-weight: normal;
}
table.shipmentItemList {
td {
&.title, &.author, &.options {
font-size: 1.0em;
font-weight: normal;
}
}
}
table.shipmentItemList{
TD.title, TD.author, TD.options {
font-size: 1.0em;
font-weight: normal;
}
}
如果你想在CSS中做这类事情,你就必须研究更少或更少的SASS。因为你的代码是标准CSS格式的,所以一切都很好。