我有一组六个百分比宽度的框,每行应该显示三个。它们向左浮动并且大小相同,但在看似随机的浏览器宽度下,第四项一直浮动到右侧,最后两项被推到第三行。每个标记都是相同的,并且图像的大小都相同,所以我不确定是什么原因造成的。该页面存在于此处。当您调整浏览器宽度时,您会明白我的意思。
这是HTML:
<div class="large-12 columns">
<div class="promoItem">
<img src="img/promo/groupFitness.jpg">
<div class="colorBG"></div>
<div class="promoLabel">Group Fitness Classes</div>
</div>
<div class="promoItem">
<img src="img/promo/mealPlans.jpg">
<div class="colorBG"></div>
<div class="promoLabel">Custom Meal Plans</div>
</div>
<div class="promoItem">
<img src="img/promo/personalTraining.jpg" />
<div class="colorBG"></div>
<div class="promoLabel">Personalized Fitness Plans</div>
</div>
<div class="promoItem">
<img src="img/promo/fitnessVideos.jpg">
<div class="colorBG"></div>
<div class="promoLabel">Fitness Videos</div>
</div>
<div class="promoItem">
<img src="img/promo/healthyRecipes.jpg">
<div class="colorBG"></div>
<div class="promoLabel">Healthy Recipes</div>
</div>
<div class="promoItem">
<img src="img/promo/emailSignup.png" />
<div class="colorBG"></div>
<div class="promoLabel">Join our mailing list</div>
</div>
</div>
和CSS:
div.promoItem {
position: relative;
float: left;
width: 29.333333%;
margin: 0 2% 20px 2%;
}
div.promoItem img {
z-index: 1;
max-width: 100%;
}
div.promoItem div {
position: absolute;
left: 0;
right: 0;
bottom: 0;
padding: 4px;
height: 35px;
line-height: 26px;
text-align: center;
overflow: hidden;
}
div.promoItem div.colorBG {
z-index: 2;
background-color: #FFD700;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=75)";
filter: alpha(opacity=75);
opacity: 0.75;
}
div.promoItem:hover div.promoLabel {
background-color: #FFD700;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
filter: alpha(opacity=100);
opacity: 1;
}
div.promoItem div.promoLabel {
z-index: 3;
color: #0D42C0;
}