我正在向左侧表格单元格添加填充,但中心和右侧单元格也有顶部填充。如何删除中间和右侧单元格的填充?
中间和右边的单元格仍然顶部填充。
<!doctype html>
<html>
<head>
<style>
* {
margin: 0;
padding: 0;
}
.left, .center, .right {
display: table-cell;
width: 100px;
height: 50px;
}
.center, .right {
display: table-cell;
width: 100px;
padding: 0;
}
.left {
padding: 10px;
background: yellow;
}
.center {
background: pink;
}
.right {
background: orange;
}
</style>
</head>
<body>
<div class="left">a</div>
<div class="center">b</div>
<div class="right">c</div>
</body>
</html>
最佳答案
我想你想要的是使用vertical-align:top;
.left, .center, .right {
display: table-cell;
width: 100px;
height: 50px;
vertical-align:top;
}
关于html - 无法删除表格单元格中的顶部填充或空格,为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27467129/