html - 如何使用 :not() 选择器选择表?
问题描述
我有一个div
有一个段落和一个表格的。
我想font-size
使用选择器更改段落的:not()
。
我尝试了以下操作,但无法使用此选择器选择表格元素。
div :not(table){font-size:5px;}/*not working*/
<div><p>....</p><table>....</table></div>
解决方案
您要选择不是表格的 div 的子项,因此您可以在 div 上使用 > 选择器
div > :not(table)
这是片段:
body{
width: 100%;
background-color: #7df3e0;
font-size: 24pt;
}
div > :not(table){
font-size: 5px;
}
<div>
<p>paragraph</p>
<table border="1">
<thead>
<tr class="trr">
<th>Roll</th>
<th>Name</th>
<th>GPA</th>
</tr>
</thead>
<tbody>
<tr>
<th>01</th>
<th>Nur</th>
<th>5.0</th>
</tr>
<tr>
<th>02</th>
<th><a href="https://www.prothomalo.com">prothomalo</a></th>
<th>5.0</th>
</tr>
<tr>
<th>03</th>
<th>Nur</th>
<th>5.0</th>
</tr>
<tr>
<th>04</th>
<th>Nur</th>
<th>5.0</th>
</tr>
</tbody>
</table>
</div>
推荐阅读
- php - 显示几个 woo-commerce 产品类别的特定页面模板
- matlab - 如何为轮廓设置 uicontextmenu (MATLAB2014b)
- spring-boot - JSP文件未加载到浏览器中,但文件名在spring Boot Application中的浏览器中显示为字符串
- vba - 如何通过 Selenium 和 VBA 根据 html 从第二行和第二列中提取文本 8
- android - 在 android studio 3.1.4 中不能使用“?attr/actionBarSize”
- arrays - 如何使用 IText 按大小按 PDF 拆分并存储到字节数组中
- java - Java初始化类
- database - 数据库语言中的队列城市位置独立
- angular - 来自 CDN 的 Angular 2
- apache-spark - 减少 Apache Spark 启动时间