.container {
width: 850px;
padding: 0;
display: table;
margin-left: auto;
margin-right: auto;
}
.row {
display: table-row;
margin-bottom: 30px;
/* HERE */
}
.home_1 {
width: 64px;
height: 64px;
padding-right: 20px;
margin-right: 10px;
display: table-cell;
}
.home_2 {
width: 350px;
height: 64px;
padding: 0px;
vertical-align: middle;
font-size: 150%;
display: table-cell;
}
.home_3 {
width: 64px;
height: 64px;
padding-right: 20px;
margin-right: 10px;
display: table-cell;
}
.home_4 {
width: 350px;
height: 64px;
padding: 0px;
vertical-align: middle;
font-size: 150%;
display: table-cell;
}
<div class="container">
<div class="row">
<div class="home_1"></div>
<div class="home_2"></div>
<div class="home_3"></div>
<div class="home_4"></div>
</div>
<div class="row">
<div class="home_1"></div>
<div class="home_2"></div>
</div>
</div>
我的问题是相对于HERE
CSS中标记的行。我发现行之间的距离太近了,因此我尝试添加底边距来分隔它们。不幸的是,它不起作用。我必须将页边距添加到表格单元格中以分隔行。
此行为背后的原因是什么?
另外,可以像我正在使用的那样使用此策略执行布局:
[icon] - text [icon] - text
[icon] - text [icon] - text
还是有更好的策略?
如果要在行之间留出空间,请将padding-bottom添加到home_4。
—
Satbir Kira