【发布时间】:2014-10-20 19:37:38
【问题描述】:
要查看问题是什么,请在 jsfiddle 中调整结果窗口的大小,以便连续三个项目。如您所见,第三项与其他项不一致,显然是因为它的内容较少。我怎样才能解决这个问题?我尝试了 float:left,但它们不再居中,这是必不可少的。
HTML
<div id="red">
<figure class="red"><img src="images/redaktion_fotos/kubi.jpg" class="profil" /> <figcaption>Kubilay Yalçın</figcaption>
<p><img src="/templates/askanier/images/icons/crown.png" /> Chefredakteur</p>
<p><img src="/templates/askanier/images/icons/askanier.png" /> Allgemein</p><br>
<p><a href="https://www.facebook.com/kubyal" class="button fb" target="_blank">Kontakt</a><a href="mailto:kubilayyalcin@yahoo.de" class="button mail">Kontakt</a></p>
</figure>
<figure class="red"><img src="images/redaktion_fotos/simon.jpg" class="profil" /> <figcaption>Simon Mathewson</figcaption>
<p><img src="/templates/askanier/images/icons/cursor.png" /> Website</p>
<p><img src="/templates/askanier/images/icons/askanier.png" /> Allgemein</p>
<br>
<p><a href="https://www.facebook.com/simon.mathewson" class="button fb" target="_blank">Kontakt</a></p>
</figure>
<figure class="red"><img src="images/redaktion_fotos/sophie.jpg" class="profil" /> <figcaption>Sophie Altstädt</figcaption>
<p><img src="/templates/askanier/images/icons/sport.png" /> Sport und Fitness</p><br>
<p><a href="https://www.facebook.com/sophie.eatme" class="button fb">Kontakt</a></p>
</figure>
<figure class="red"><img src="images/redaktion_fotos/safa.jpg" class="profil" /> <figcaption>Safa Hazem</figcaption>
<p><img src="/templates/askanier/images/icons/karikatur.png" /> Karikaturistin</p><br>
<p><a href="https://www.facebook.com/safa.ha.921" class="button fb" target="_blank">Kontakt</a></p>
</figure>
<figure class="red"><img src="images/redaktion_fotos/vicky.jpg" class="profil" /> <figcaption>Vicky Mielczarek</figcaption>
<p><img src="/templates/askanier/images/icons/fashion.png" /> Mode und Lifestyle</p><br>
<p><a href="https://www.facebook.com/vicky.mk.5" class="button fb target="_blank"">Kontakt</a></p>
</figure>
</div>
CSS
#red {
padding: 0 0 20px 0;
text-align: center;
}
#red::after {
content: "";
display: block;
height: 0;
clear: both;
}
figure.red {
margin: 30px 15px 0 15px;
display: inline-block;
background-color: #ddd;
border: 1px solid #ccc;
padding: 10px 10px 0 10px;
font-family: dejan;
height: 300px;
}
figure.red:hover {
border: 1px solid #bbb;
}
figure.red img.profil {
width: 150px;
height: 150px;
margin: 0 auto;
display: block;
}
figure.red figcaption {
color: white;
background: url(../images/figcaption.png) no-repeat;
width: 236px;
height: 44px;
font-weight: bold;
text-shadow: -1px -1px 0px rgba(0,0,0,0.5);
padding-top: 25px;
margin: -12px auto 0 auto;
text-align: center;
}
figure.red p {
margin: 0;
text-align: center;
}
figure.red .button {
margin-bottom: -10px;
padding: 10px 15px 10px 40px;
background-position: center left 15px;
}
figure.red .fb {
background-image: url(../images/icons/fb.png);
background-color: #3b5998;
background-repeat: no-repeat;
}
figure.red .mail {
background-image: url(../images/icons/mail.png);
background-color: #666;
background-repeat: no-repeat;
}
figure.red figcaption a.button:last-child {
margin-left: 5px;
}
【问题讨论】:
-
添加一个空的
<p>元素。 -
@nalply 这不是一个真正令人满意的解决方案 :)
-
这就是我将其作为评论发布的原因:-P
-
为什么人们不赞成这个?
-
不是我,你看stackoverflow.com/help/how-to-ask。你的问题只对你有用。这对您来说是一个快速解决方案,对其他人没有帮助。
标签: css html position css-float css-position