css - 如何将多个 css 类属性合并到一个类中

标签 css

我对不同的 4 个类具有相同的属性。所以我想减少代码重量。那么我怎样才能把它作为一个单一的公共(public)类。

    .iass-general-config-wrapper h2
           {
               padding-bottom: 1px!important;
            }
    .iass-workload-config-wrapper h2
           {
               padding-bottom: 1px!important;
            }
     .iass-network-config-wrapper h2
            {
                padding-bottom: 1px!important;
              }
      .vdi-review-wrapper
            {
                 padding-bottom: 1px!important;
             } 

最佳答案

您可以将它们“合并”在一起作为多选择器规则

.iass-general-config-wrapper h2,
.iass-workload-config-wrapper h2,
.iass-network-config-wrapper h2,
.vdi-review-wrapper
{
    padding-bottom: 1px!important;
}

或者如评论中所述,您可以简单地创建一个新类并应用它,从而减少代码量

.padding-bottom
{
     padding-bottom: 1px !important;
}

关于css - 如何将多个 css 类属性合并到一个类中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28320288/

相关文章:

javascript - 生成的标签不加载 css

javascript - 组织结构图未显示所有标签

php - 无法附加相同的 div

javascript - 如何在单击时平滑地扩展边框底部

html - 固定数量的 CSS 调整大小

javascript - 如何在Chrome中放一个类似Gmail的蓝点?

javascript - 在保持边距的同时禁用浏览器打印页眉和页脚,但也在第 2、3 页等上

html - 在等高列内 Bootstrap 等高行

HTML - Dart如何显示RTF等富文本文档

html - 无论如何在 Firebug 中选择一个部分并找到相关的 html 和 css?