【发布时间】:2013-06-09 06:15:51
【问题描述】:
我一直在尝试找到一个适用于 IE 的解决方案,或者让 IE 玩得更好(哈!)。
我想要做的:创建一个包含图像和标题的 div,但不允许标题将 div 拉伸得比图像更宽,而是打破文本行(换行),而不必指定宽度这可以动态使用。
到目前为止,我发现可以在 IE 以外的浏览器中使用:
<div id="featured-image">
<img src="images/cats-brenda.jpg" alt="Litter of Kittens"/><br/>
<span class="caption">Litter of kittens at the Sacramento County Animal
Shelter (Image by: Brenda Bongiorno)</span>
</div>
CSS:
#featured-image {
display: table; min-width: 1px; float: left; margin-right: 10px;}
#featured-image .caption {display: table-caption; caption-side: bottom;}
这很好用,只是在 IE 中不行。相反,在 IE 中,由于标题比图像宽,它会拉伸整个 div 以匹配标题,而不是图像,将其推入文章中。
我会发布屏幕截图,但我必须“拥有 10 个声望”才能做到这一点:(
【问题讨论】:
-
这仅在 IE7 中不起作用,对吧?
-
可以试试
max-width:100% -
我已经尝试过 Dominic Bc :( 而且它似乎适用于所有 IE 9 及更低版本。我还有一个 div 不介意它的位置并拉伸容器的 100% 宽度而不是避免表格(或 div)。
标签: html css image internet-explorer caption