html - 如何在 css 中使用类中的特定单词?

标签 html css css-selectors

我有一些'<a> <i> <label>'在我的页面中,如下所示

<a class="icon-home"></a>
<label class="icon-pencil"></label>
<i class="icon-display"></i>

我需要用 margin-right:10px 创建 css当类(class)以 "icon-" 开始时

像下面这样的东西:

<style>
.icon-* {margin-right:10px}
</style>

最佳答案

试试这个:

[class^="icon-"], [class*=" icon-"] {
    margin-right: 10px;
}

关于html - 如何在 css 中使用类中的特定单词?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17107682/

相关文章:

css - 带有 :target pseudo adding active style w/o Javascript 的标签

css - 使用 CSS 左右对齐图像

html - 如何在 Sass 中使用 lang() 选择器?

html - div 网格的最后一行稍微未对齐

css - 为什么这个 css 覆盖了另一个?

html - 一般兄弟选择器 - 奇怪的行为

css - css 中的兄弟选择器

javascript - 图像 slider - 移动和桌面的不同图像

html - 通过 JSF 呈现时, Bootstrap 按钮没有水平填充

html - 如何使用CSS创建横向div?