我在Twitter Bootstrap中看到了这个选择器:
.show-grid [class*="span"] {
background-color: #eee;
text-align: center;
border-radius: 3px;
min-height: 30px;
line-height: 30px;
}
有人知道这种技术叫什么,以及它的作用吗?
我在Twitter Bootstrap中看到了这个选择器:
.show-grid [class*="span"] {
background-color: #eee;
text-align: center;
border-radius: 3px;
min-height: 30px;
line-height: 30px;
}
有人知道这种技术叫什么,以及它的作用吗?
这是一个属性通配符选择器。在您提供的示例中,它查找任何子元素(包括嵌套子元素)位于.show-grid
下,且具有类名中包含span
的元素。
因此,它将选择此示例中的<strong>
元素:
<div class="show-grid">
<strong class="span6">Blah blah</strong>
</div>
你还可以搜索「以...开头的」内容。
div[class^="something"] { }
这个可以用在像这样的情况中:
<div class="something-else-class"></div>
以“ends with…”结尾
div[class$="something"] { }
这将适用于
<div class="you-are-something"></div>
优秀的参考资料
div[class^="something"] { }
这个“以某个值开头”的选择器只在元素只包含一个类时有效,或者当元素包含多个类时,该选择器也只匹配最左边的那个类。 - Nahndiv[class~="something"]
来查找空格分隔列表(例如类)中的匹配项,以及 div[class|="something"]
用于在连字符分隔列表中进行匹配,例如在上面的 you-are-something 类名中匹配 something。 - Ruskin.show-grid [class*="span"]
这是一个CSS选择器,它选择所有具有类show-grid的元素,并且其中包含一个类名为contains且名称为span的子元素。
以下内容:
.show-grid [class*="span"] {
<div class="show-grid">
<div class="span">.span</div>
<div class="span6">span6</div>
<div class="attention-span">attention</div>
<div class="spanish">spanish</div>
<div class="mariospan">mariospan</div>
<div class="espanol">espanol</div>
<div>
<div class="span">.span</div>
</div>
<p class="span">span</p>
<span class="span">I do GET HIT</span>
<span>I DO NOT GET HIT since I need a class of 'span'</span>
</div>
<div class="span">I DO NOT GET HIT since I'm outside of .show-grid</span>
<span>
元素本身,其他所有元素都被选中。span6
:这是Bootstrap 2的脚手架技术,它根据12个部分将一个区域划分为水平网格。因此,span6
的宽度为50%。
- 在当前版本的Bootstrap(v.3和v.4)中,您现在可以使用.col-*
类(例如col-sm-6
),它还指定了一个媒体断点,以处理当窗口缩小到一定大小时的响应能力。请查看Bootstrap 4.1和Bootstrap 3.3.7获取更多文档。我建议现在使用较新的Bootstrap版本。^=
用于字符串开头,$=
用于字符串结尾。这是一个很好的参考,其中包含了一些CSS选择器。spanX
(这里X为整数),但如果存在其他选择器以 span
结尾,则它也将遵循这些规则。body .ForwardRef-root-198 .aura-ag-grid .ag-row:hover, body .ForwardRef-root-198 .ag-details-grid .ag-row:hover {
background-color: #2196f35c !important;
}
解决方案:
body div[class*="ForwardRef-root-"] .aura-ag-grid .ag-row:hover, body div[class*="ForwardRef-root-"] .ag-details-grid .ag-row:hover {
background-color: #2196f35c !important;
}
参考资料:链接