html的table表格的td设置1px,浏览器效果不一致问题解决
解决前:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
border: none;
border-spacing: 0;
}
table {
width: 100px;
margin: 20px;
border-collapse: collapse;
border-left: 1px solid #000;
border-top: 1px solid #000;
}
td {
border-right: 1px solid;
border-bottom: 1px solid;
border-color: #000;
}
</style>
</head>
<body>
<table>
<tr>
<td>11</td>
</tr>
<tr>
<td>22</td>
</tr>
<tr>
<td>33</td>
</tr>
</table>
</body>
</html>
解决后:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
border: none;
border-spacing: 0;
}
table {
width: 100px;
margin: 20px;
border-collapse: separate;
border-left: 1px solid #000;
border-top: 1px solid #000;
}
td {
border-right: 1px solid;
border-bottom: 1px solid;
border-color: #000;
}
</style>
</head>
<body>
<table>
<tr>
<td>11</td>
</tr>
<tr>
<td>22</td>
</tr>
<tr>
<td>33</td>
</tr>
</table>
</body>
</html>
注意:
这里使用边框的table的上左和td的右下组成的边框效果;
经过测试发现是 border-collapse: collapse
属性的问题,这里改为border-collapse: separate
解决问题,具体什么原因暂时没,有懂的大佬留言,感谢;