如何使用多id简化css';s

如何使用多id简化css';s,css,Css,我试图清理一下这个CSS,因为我想对它应用相同的样式,但它很混乱。有没有可能简化这一点 #collection.shop-gioventu-new-york .container .twelve.columns, #index .container .twelve.columns, #index-v2 .container .twelve.columns { width: 100% !important; } 在html中,将class=“fullWidth”类添加到

我试图清理一下这个CSS,因为我想对它应用相同的样式,但它很混乱。有没有可能简化这一点

#collection.shop-gioventu-new-york .container .twelve.columns,
#index .container .twelve.columns,
#index-v2 .container .twelve.columns          
{
   width: 100% !important;
}
在html中,将class=“fullWidth”类添加到任何需要此样式的内容中

<div id="collection" class="shop-gioventu-new-york container twelve columns fullWidth">...</div>
<div id="index" class="container twelve columns fullWidth">...</div>
<div id="index-v2" class="container twelve columns fullWidth">...</div>
。。。
...
...

“清理”css涉及在html中添加过多类或css中添加过多选择器之间进行平衡。在这种情况下,您必须决定什么对您的应用程序最有意义

您需要向我们显示标记,并在开始时告诉我们需要id选择器的原因。是因为您不想在其他父项下选择
.container.seven.columns
?如果是,为什么不给其他人分配一个公共类?还有,你有多少这样不同的父母?如果只是一个,考虑使用<代码>:NOTE()/<代码>。这里有太多的未知数无法给出完整的答案。这就是为什么建议人们不要使用ID。对当前使用ID选择器的所有元素使用一个公共类。我已经清理了一点,现在看起来更好了:-)@Harry所以我使用ID,因为它们引用不同的页面。所以我只是想把目标锁定在这三页上。有什么办法让它更整洁吗?@rs19:你的答案在我之前的评论和Katana314的评论中。为什么不分配一个公共类并使用它呢?
<div id="collection" class="shop-gioventu-new-york container twelve columns fullWidth">...</div>
<div id="index" class="container twelve columns fullWidth">...</div>
<div id="index-v2" class="container twelve columns fullWidth">...</div>