我正在向我的左表格单元格添加填充,但中心和右侧单元格也会获得顶部填充.如何从中心和右侧单元格中删除填充?
中心和右侧细胞仍然是顶部填充.
<!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>
Run Code Online (Sandbox Code Playgroud)
我想你想要的就是用 vertical-align:top;
.left, .center, .right {
display: table-cell;
width: 100px;
height: 50px;
vertical-align:top;
}
Run Code Online (Sandbox Code Playgroud)
演示:http://jsfiddle.net/o50s8ucj/2/