我试图为表格标题添加底部框阴影,但由于某种原因,阴影也出现在侧面。下面是我正在尝试使用的代码。
#customers {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 100%;
}
#customers td,
#customers th {
padding: 8px;
}
#customers th {
box-shadow: 0 1px 2px 0px grey;
}
<table id="customers">
<tr>
<th>Company</th>
<th>Contact</th>
<th>Country</th>
</tr>
<tr>
<td>Alfreds Futterkiste</td>
<td>Maria Anders</td>
<td>Germany</td>
</tr>
<tr>
<td>Berglunds snabbköp</td>
<td>Christina Berglund</td>
<td>Sweden</td>
</tr>
<tr>
<td>Centro comercial Moctezuma</td>
<td>Francisco Chang</td>
<td>Mexico</td>
</tr>
</table>
我正在寻找的是一个带有 blur:2px
、spread:0px
、y-offset:1px
和 的盒子阴影>x-offset:0px
最佳答案
猜猜这可能就是您正在寻找的内容,我对 box-shadow
进行了一些编辑,并将表格数据 td
和表格头 th 居中
为了使其外观好看
#customers {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 100%;
}
#customers td,
#customers th {
padding: 8px;
/* added */
text-align: center;
}
#customers th {
/* edited */
box-shadow: 0px 2px 0px rgba(128,128,128, .15);
}
<table id="customers">
<tr>
<th>Company</th>
<th>Contact</th>
<th>Country</th>
</tr>
<tr>
<td>Alfreds Futterkiste</td>
<td>Maria Anders</td>
<td>Germany</td>
</tr>
<tr>
<td>Berglunds snabbköp</td>
<td>Christina Berglund</td>
<td>Sweden</td>
</tr>
<tr>
<td>Centro comercial Moctezuma</td>
<td>Francisco Chang</td>
<td>Mexico</td>
</tr>
</table>
关于html - 如何为表格标题添加底部框阴影,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62886553/