假设我有
<div class="dataTables_filter">
<label>
Search: <input type="text">
</label>
</div>
我想用 css 隐藏文本“Search:”,如何匹配文本“Search:”并应用 display:none?
我尝试将文本匹配为标签的第一个子元素,但没有用,它还隐藏了输入
.dataTables_filter label:first-child {
display: none;
}
编辑:请从字面上理解我的问题:即无法以任何方式更改 HTML,只能利用 css。
最佳答案
纯 CSS
您可以使用 the :first-line
pseudo element , 结合 font-size
为 0:
.dataTables_filter:first-line {
font-size: 0;
}
关于html - CSS:匹配 block 内的第一个单词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22374132/