我有文本和三個圖像以垂直對齊基線。我已經使用垂直對齊屬性通過文本底部對齊項目,但它仍然沒有正確對齊。 如何通過基線垂直對齊文字和圖像?
請參閱透明黑匣子幫助您查看基線問題的屏幕截圖。
.container {
font-size: 16px;
}
.ayc_cooperation {
margin: 0 5% 0 5%;
font-size: 0.75rem;
font-weight: 300;
color: #535353;
}
.ayc_cooperation:before {
content: "";
display: table;
clear: both;
}
.ayc_cooperation:after {
content: "";
display: block;
height: 6.5rem;
}
.ayc_cooperation_ini_logo {
float: left;
width: 9.6875rem;
height: 4.5rem;
}
.ayc_cooperation_ini_logo img {
width: 100%;
height: 100%;
}
.ayc_co_container {
float: right;
line-height: 8;
height: 4.5rem;
}
.ayc_co_container img {
max-width: 100%;
max-height: 100%;
}
.ayc_co_container img:first-child {
width: 7.5rem;
}
.ayc_co_container img:nth-child(2) {
width: 8rem;
}
.ayc_co_container img {
margin-right: 2.5rem;
}
.ayc_co {
display: inline-block;
margin-left: 2.5rem;
font-size: 0.75rem;
line-height: 14px;
vertical-align: text-bottom;
}
.ayc_de_lebe_ev_img {
width: 8rem;
}
.ayc_de_lebe_ev_img img {
max-width: 100%;
height: auto;
}
.ayc_de_lebe_img {
width: 7.5rem;
}
.ayc_de_lebe_img img {
max-width: 100%;
height: auto;
}
.ayc_gilead_img {
width: 6rem;
}
.ayc_gilead_img img {
max-width: 100%;
height: auto;
}
<div class="container">
<div class="ayc_co_container">
<div class="ayc_co_text ayc_co">
Eine Kooperation von:
</div>
<div class="ayc_de_lebe_img ayc_co">
<img src="http://presse.bist-du-chris.de/wp-content/themes/ayc_press/assets/media/img/[email protected]" alt="Deutsche Leberstiftung">
</div>
<div class="ayc_de_lebe_ev_img ayc_co">
<img src="http://presse.bist-du-chris.de/wp-content/themes/ayc_press/assets/media/img/deutsche-leberhilfe[email protected]" alt="Deutsche Leberhilfe e.V">
</div>
<div class="ayc_gilead_img ayc_co">
<img src="http://presse.bist-du-chris.de/wp-content/themes/ayc_press/assets/media/img/[email protected]" alt="Gilead Sciences GmbH">
</div>
</div>
</div>
你不能這樣做,因爲你的形象是一個位圖圖像將如何在Web瀏覽器知道在哪裏的基準是什麼? – Terry
元素本身是對齊的,圖像中的文本不是。 CSS不能神奇地將基於文本的元素放置在圖像中。您需要編輯圖像,以便文本與圖像底部對齊。 –