我知道我可以根据其名称将CSS样式应用于元素:
input[name=description] {
width: 200px;
}
但是是否可以将CSS样式应用于名称中包含特定字符串的元素?
想象几个输入:
<input type="text" name="projectDescription"/>
<input type="text" name="themeDescription"/>
<input type="text" name="methodologyDescription"/>
<input type="text" name="somethingElse"/>
etc...
因此,我只想将样式应用于名称包含单词“ Description”的输入。无需编写脚本就能做到吗?
是的你可以:
input[name*="Description"] {
width: 200px;
}
[attr]
Represents an element with an attribute name of attr.
[attr=value]
Represents an element with an attribute name of attr
and whose value is exactly "value".
[attr~=value]
Represents an element with an attribute name of attr
whose value is a whitespace-separated list of words,
one of which is exactly "value".
[attr|=value]
Represents an element with an attribute name of attr.
Its value can be exactly “value” or can begin with “value”
immediately followed by “-” (U+002D). It can be used for
language subcode matches.
[attr^=value]
Represents an element with an attribute name of attr
and whose value is prefixed by "value".
[attr$=value]
Represents an element with an attribute name of attr
and whose value is suffixed by "value".
[attr*=value]
Represents an element with an attribute name of attr
and whose value contains at least one occurrence of
string "value" as substring.
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句