这很可能是重复的,但我一直没能找到任何与相当的东西,相当于一样。我想在图像下方填充空格以阻止文本完全包裹。在视觉方面:垂直向下展开图像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