我知道這已被問了很多很多次,但我仍然無法完成自己想要的東西。我看過各種網站尋求幫助,如Here和Here以及使用顯示錶垂直對齊,行高度等Div與圖像垂直對齊
這裏就是我試圖完成(我知道我可能要添加更多divs)。文本並不總是恆定的,所以我不能只是設置填充並完成它,因爲紅色和藍色的文本可能會改變長度。
下面是一個簡單的jsfiddle什麼我目前有:http://jsfiddle.net/gP2U8/9/
<div class="container">
<div class="left">
<img src="http://www.gadgets-for-men.co.uk/wp-content/themes/revolution_tech-20/images/rss-icon-50.gif" />
<span>This is text below the image</span>
</div>
<div class="right">
<span>This is text to the right of the image, will usualy contain a lot of text. This is text to the right of the image, will usualy contain a lot of text. This is text to the right of the image, will usualy contain a lot of text. This is text to the right of the image, will usualy contain a lot of text.</span>
</div>
</div>
.container{
border: 1px solid black;
width: 400px;
height: auto;
position: relative;
display: inline-block;
}
.left{
float:left;
width: 25%;
}
.right{
float: right;
width: 75%;
}
.left, .right{
margin-top: 25px;
margin-bottom: 25px;
}
不完全是,如果添加更多的文字,你會看到一個問題。 http://jsfiddle.net/d4DaV/2/我希望下面的圖像和文字保持垂直對齊以及 – sl133 2013-03-17 19:10:42
對齊在哪裏?在中間?在底部?目前它排在最前面。 – MattDiamant 2013-03-17 19:12:25
在中間垂直對齊,以便它居中。你可以在我的模擬圖像中看到,左側將停留在右側文本的中間。 – sl133 2013-03-17 19:12:55