当我将任何内容放入下面三个的第一个div(以内联块显示)时,第一个div移到下一行。
.container-testimonials {
text-align: center;
background: teal;
margin: 20px auto;
font-size: 0;
}
.clients {
padding-top: 60px;
}
.clients h3 {
font-size: 2rem;
font-weight: normal;
}
.box8,
.box9,
.box10 {
display: inline-block;
height: 250px;
width: 31.3%;
background-size: cover;
margin: 1%;
background: #F25E5E;
border-radius: 10px;
}
.box8 p {
color: #000;
font-size: 1rem;
}
<div class="container-testimonials">
<div class="clients">
<h3>WHAT CLIENTS SAY</h3>
</div>
<div class="box8">
<p>Text</p>
</div>
<div class="box9"></div>
<div class="box10"></div>
</div>
我相当确定这与<p>
标签为每个div块的宽度增加的额外空格有关,该宽度设置为31.3%,其余1%用于填充,而2 / 3%用于另外两个div。
答案 0 :(得分:0)
将vertical-align: top;
添加到框中可以使它们正确地在顶部对齐。
答案 1 :(得分:0)
在vertical-align:top;
上添加.box8,.box9,.box10
.box8,
.box9,
.box10 {
display: inline-block;
height: 250px;
width: 31.3%;
background-size: cover;
margin: 1%;
background: #F25E5E;
vertical-align:top;
border-radius: 10px;
}