如何选择所有ID以特定字符串开头和结尾的元素?
在CSS中,如何选择所有<tr>元素id开头section_和结尾的元素_dummy?
例如,我想选择并应用以下样式<tr>:
<tr id="section_5_1_dummy"> <td>...</td>
</tr>
<tr id="section_5_2_dummy">
<td>...</td>
</tr>
回答:
以下CSS3选择器将完成此工作:
tr[id^="section_"][id$="_dummy"] { height: 200px;
}
该^表示什么id应该开始。
该$表示什么id应该结束。
id本身可以用另一个属性替换,例如href,应用于时(例如)<a>:
a[href^="http://www.example.com/product_"][href$="/about"] { background-color: red;
}
以上是 如何选择所有ID以特定字符串开头和结尾的元素? 的全部内容, 来源链接: utcz.com/qa/424157.html

