CSS将父元素下的子元素分组

问题描述 投票:0回答:1

有可能避免这种重复的CSS声明吗?

不知何故,table thtable td只在一个weather-component下组

weather-component table th, 
weather-component table td {
    text-align: center !important;
}

就像是...

weather-component (table th, table td) {
    text-align: center !important;
}
css css3 css-selectors
1个回答
0
投票

在CSS中不可能。但是例如在LESS中,你可以把它写成

.weather-component table {
   th, td {
    text-align: center !important;
  }
}
© www.soinside.com 2019 - 2024. All rights reserved.