我需要让这张桌子看起来像在图像中表格中的蓝线是我需要如何制作它请帮助我提前谢谢
<style>
td, th {
text-align: left;
padding: 8px;
}
table{
border: 1px solid #dddddd;
}
</style>
<table>
<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>Centro comercial</td>
<td>Francisco Chang</td>
<td>Mexico</td>
</tr>
<tr>
<td>Ernst Handel</td>
<td>Roland Mendel</td>
<td>Austria</td>
</tr>
</table>
答案 0 :(得分:2)
在表格中添加border-collapse:collapse
,这会将表格的边框折叠为single border
,然后您可以将border-right
添加到标签的td。
td, th {
text-align: left;
padding: 8px;
}
th:nth-child(1), td:nth-child(1){
border-right:1px solid blue; /*Add this*/
}
th:nth-child(2), td:nth-child(2){
border-right:1px solid blue; /*Add this*/
}
table{
border: 1px solid #dddddd;
border-collapse:collapse;/*Add this*/
}
&#13;
<table>
<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>Centro comercial</td>
<td>Francisco Chang</td>
<td>Mexico</td>
</tr>
<tr>
<td>Ernst Handel</td>
<td>Roland Mendel</td>
<td>Austria</td>
</tr>
</table>
&#13;
答案 1 :(得分:1)
插入此代码:
td:not(:last-child),th:not(:last-child) {
border-right: 1px solid blue;
}
table {
border-collapse: collapse;
//more code
}
td, th {
text-align: left;
padding: 8px;
}
td:not(:last-child),th:not(:last-child) {
border-right: 1px solid blue;
}
table {
border: 1px solid #dddddd;
border-collapse: collapse;
}
<table>
<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>Centro comercial</td>
<td>Francisco Chang</td>
<td>Mexico</td>
</tr>
<tr>
<td>Ernst Handel</td>
<td>Roland Mendel</td>
<td>Austria</td>
</tr>
</table>