這很可能是重複的,但我一直沒能找到任何與相當的東西,相當於一樣。我想在圖像下方填充空格以阻止文本完全包裹。在視覺方面:垂直向下展開圖像CSS填充空間
我有這樣的:
| /---\ BLAHBLAH | |img| blah | \---/ blah | blah | blah | ...
我想這一點:
| /---\ BLAHBLAH | |img| blah | \---/ blah | blah | blah | ...
我該怎麼辦?
這很可能是重複的,但我一直沒能找到任何與相當的東西,相當於一樣。我想在圖像下方填充空格以阻止文本完全包裹。在視覺方面:垂直向下展開圖像CSS填充空間
我有這樣的:
| /---\ BLAHBLAH | |img| blah | \---/ blah | blah | blah | ...
我想這一點:
| /---\ BLAHBLAH | |img| blah | \---/ blah | blah | blah | ...
我該怎麼辦?
你可以這樣寫:
<img src="bla.png" style="float:left;" />
<div style="overflow:hidden">Some text</div>
如果父div具有text-align:left,則這不起作用。但是,它適用於我的目的(或單獨)。 – astex
float屬性添加到這兩個圖片和文字,圖像添加到一個div和調整到左側並設置div高度= 100%。我想這會工作
如果你的HTML是這樣的:
<div class="content-container">
<p><img src="whatever" /> text text text text text
text text text text text text text text text text text
text text text text text text text text text text text
text text text text text text text text text text text
text text text </p>
</div>
那麼有沒有辦法,只用CSS來做到這一點。添加一些jQuery的味道一樣:
// Loop through all the images
$('.content-container img').each(function(){
// Get image height
var imageHeight = $(this).height();
// Get container's height
var containerHeight = $(this).parent('.content-container').height();
// Set image bottom margin to container's height - image height
jQuery(this).css('margin-bottom', (containerHeight - imageHeight) + 'px');
})
這下面,可惜沒絕對沒有......「填充底」還沒有采取任何行動。 – astex
HTML:
<div class="content">
<img src="thumbnail.jpg" width="50" height="50" />
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis ligula arcu, luctus nec elementum quis, condimentum a lectus. Suspendisse potenti. Proin neque diam, dictum ac elementum scelerisque, aliquet eget diam....</p>
</div>
CSS:
.content {
padding: 0 0 0 75px; /* 75px being the width of the thumbnail + how much space you want to put between it and your text */
position: relative; /* So the thumbnail is relative to this */
}
.content img {
left: 0;
position: absolute;
top: 0;
}
這會垂直縮放圖像,這不是所需的效果。 – astex
誤讀了問題,更新了答案。 –
如果您不介意使用表格,那麼您可以輕鬆解決您的問題。
像這樣:
<table>
<tr>
<td><img src="yourImage.jpg" alt="" /></td>
<td>Your text... blah blah blah..... blah</td>
</tr>
</table>
您可以設置TD的寬度爲您的要求,使所有的TD具有相同的大小。
讓你的當前HTML成小提琴和張貼。 – mithunsatheesh
是的..請添加一些代碼片段來看看。塗鴉不會工作:) –
這是一個模板,但我會嘗試做一個通用的例子。 [這裏](http://pastebin.com/4Cvd88Gf) – astex