html - 在 css 文件中组合 css 类

标签 html css

假设我有以下 css 规则:

.blah { Rules }

我就这样使用它

<div class="blah">

现在假设,我需要在我的文档中的某处添加 margin-bottom: 10px到其中一个带有类名 blah 的 div,这样我就可以让它尽可能具体,

我应该声明为

.blah.mar-bot-blah { margin-bottom: 10px; }
or 
.blah .mar-bot-blah { margin-bottom: 10px; }

将其用作 <div class="blah mar-bot-blah">

最佳答案

声明为:

.blah.mar-bot-blah { margin-bottom: 10px; }

它将匹配同时具有 .mar-bot-blah.blah 类的元素。

关于html - 在 css 文件中组合 css 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11341988/

相关文章:

javascript - 将变量传递到 document.getElementById() - Javascript

css - LESS 样式表(当 A 类悬停时更新 B 类)

css - 使用 css 设置一行标签和下拉列表的样式

javascript - ngClass 没有同时显示 2 个类

javascript - 使用 jquery 添加不适用于 html5 视频播放器的类

html - 公司名称与topnav在同一行

html - 如何将 css sprite 定位为另一个类的背景

html - 水平和垂直居中网站

javascript - 将等式转换为 CSS calc 导致 "invalid property value"

html - 仅在特定区域不透明度