[英]CSS attribute selector begin with
[class*="grid-"]{ border: 2px solid green; } [class^="grid-"]{ border: 2px solid red; }
<div class="row"> <div class="grid-sm-1-3">one</div> <div class="grid-sm-1-3">two</div> <div class="other class grid-sm-1-3">three</div> </div> <div class="layout-grid-edit">do not match at all</div>
The issue is, if the element has multiple classes then the class^="grid-="
doesn't seem to work, and I can't rely on class*="grid-"
because it also matches something like layout-grid-edit
which is not desired. 问题是,如果元素具有多个类,则
class^="grid-="
似乎不起作用,并且我不能依靠class*="grid-"
因为它还与layout-grid-edit
东西匹配layout-grid-edit
这是不希望的。
@3zzy - Give this attribute selector a try below. @ 3zzy-在下面尝试此属性选择器。 This type of selector will be effective in targeting a class attribute beginning with the whole word
grid
, immediately followed by a hyphen: 这种类型的选择器将有效地针对以整个单词
grid
开头的类属性,紧随其后的是连字符:
[class|="grid"] { border: 2px solid green; }
See if this does the trick, and let me know. 看看这是否可行,让我知道。
Replaced: 取代:
[class*="grid-"]{
}
With: 附:
[class^="grid-"],
[class*=" grid-"]{
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.