html - Css 分组多个 id`s 类

标签 html css

我有这样的东西:

<div id="attributes1"><span class="heading_fieldset"></div>
<div id="attributes2"><span class="heading_fieldset"></div>

#attributes1 .heading_fieldset {
    display:inline-block;
    width: 30px;
}
#attributes2 .heading_fieldset {
    display:inline-block;
    width: 30px;
}

我如何将 CSS 分组为类似的东西(下一个 CSS 不好...它弄乱了我的页面):

#attributes1, #attributes2 .heading_fieldset {
    display:inline-block;
    width: 30px;
}

谢谢

最佳答案

你会使用:

#attributes1 .heading_fieldset, #attributes2 .heading_fieldset {
    display:inline-block;
    width: 30px;
}

您试图将属性添加到元素:#attributes1 , 和 .heading_fieldset#attributes2 的父级.


我不知道你正在尝试做什么的完整上下文,所以这可能不起作用 - 但是,你可能只是将这些属性应用于 .heading_fieldset无需选择 parent 。这将减少一些冗余。

关于html - Css 分组多个 id`s 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19473163/

相关文章:

css - 网格垂直滚动

Javascript网页搜索定时器

html - 在使用 css 调整大小时使元素以图像为中心

html - 将 CSS 和 HTML 中的日期获取到 PDF 页脚

html - 带有 ASP.NET MVC Razor View 的 CSS。如何设置页面到设备宽度?元标记不起作用

html - 在 CSS 中设置文本框样式的最佳方式

html - 影响横幅 div 的多个 div

javascript - 以百分比而非像素调整高度和宽度

javascript - 单击幻灯片内的 span 元素时防止 slider 切换幻灯片

javascript - 需要幻灯片 div 在更改幻灯片时将元素向下推