我试图弄清楚为什么我在父 div 中平铺一系列 div 时会出现间距问题。这是小提琴:http: //jsfiddle.net/SNSvU/4/。这就是我所拥有的:
HTML
<div id="prioritiesWrapper">
<div class="priority"><div class="img">Img here</div><div class="title">This is my priority title</div></div>
<div class="priority"><div class="img">Img here</div><div class="title">This is my priority title; it's longer than the others and wraps</div></div>
<div class="priority"><div class="img">Img here</div><div class="title">This is my priority title</div></div>
<div class="priority"><div class="img">Img here</div><div class="title">This is my priority title</div></div>
<div class="priority"><div class="img">Img here</div><div class="title">This is my priority title; it's longer than the others and wraps</div></div>
<div class="priority"><div class="img">Img here</div><div class="title">This is my priority title; it's longer than the others and wraps</div></div>
<div class="priority"><div class="img">Img here</div><div class="title">This is my priority title</div></div>
<div class="priority"><div class="img">Img here</div><div class="title">This is my priority title</div></div>
<div class="priority"><div class="img">Img here</div><div class="title">This is my priority title</div></div>
<div class="priority"><div class="img">Img here</div><div class="title">This is my priority title</div></div>
CSS
#prioritiesWrapper {
color: white;
background-color: blue;
margin: 0 auto;
}
#prioritiesWrapper .priority .img {
float: left;
height: 50px;
margin: 0 15px 0 0;
}
#prioritiesWrapper .priority .title {
margin: auto 0;
}
#prioritiesWrapper div.priority {
width: 350px;
height: 80px;
display: inline-block;
margin: 10px 30px;
padding: 10px;
background-color: black;
text-align: left;
font-weight: bold;
line-height: 2em;
}
只要给定行上的优先级标题都相似(一行或两行),div 之间的间距似乎很好,但如果它们不同,它会使另一个 div 不对齐。
无论内容行如何,如何在 div 之间获得统一的间距?