我怎样才能将所有的div“推”informationbox到顶部,如下面的代码所示:
我尝试搜索这样的问题,但找不到任何可以解决我的问题的方法
.informationbox {
margin: 10px 0 20px 0;
text-align: center;
}
.informationbox > div {
margin: 0 15px;
width: 100px;
}
.informationbox > div:first-of-type {
margin-left: 0;
}
.informationbox > div:last-of-type {
margin-right: 0;
}
.informationbox .infotitle, .infotext {
text-align: left;
margin: 0;
}
.informationbox .infotitle{
font-size: 16px;
font-weight: 600;
margin-top: 5px;
}Run Code Online (Sandbox Code Playgroud)
<div class="informationbox">
<div style="display: inline-block;">
<img style="width: 100%; height: auto" src="https://c1.staticflickr.com/1/342/19541848580_7f925817c9_b.jpg" />
<p class="infotitle">Something</p>
<p class="infotext">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna </p>
</div>
<div style="display: inline-block;">
<img style="width: 100%; height: auto" src="https://c1.staticflickr.com/1/342/19541848580_7f925817c9_b.jpg" />
<p class="infotitle">Something</p>
<p class="infotext">Wall of Text</p>
</div>
<div style="display: inline-block;">
<img style="width: 100%; height: auto" src="https://c1.staticflickr.com/1/342/19541848580_7f925817c9_b.jpg" />
<p class="infotitle">Something</p>
<p class="infotext">Wall of Text</p>
</div>
</div>Run Code Online (Sandbox Code Playgroud)
添加vertical-align: top到此:
.informationbox > div {
...
vertical-align: top;
}
Run Code Online (Sandbox Code Playgroud)
.informationbox > div {
...
vertical-align: top;
}
Run Code Online (Sandbox Code Playgroud)
.informationbox {
margin: 10px 0 20px 0;
text-align: center;
}
.informationbox > div {
margin: 0px 15px;
width: 100px;
vertical-align: top;
}
.informationbox > div:first-of-type {
margin-left: 0px;
}
.informationbox > div:last-of-type {
margin-right: 0px;
}
.informationbox .infotitle, .infotext {
text-align: left;
margin: 0;
}
.informationbox .infotitle{
font-size: 16px;
font-weight: 600;
margin-top: 5px;
}Run Code Online (Sandbox Code Playgroud)