我有一个容器同时包含图像和文本元素。
<div class="container">
<img id="image" src="http://dummyimage.com/200">
<span class="text">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
</span>
</div>
所需行为是div应该包裹图片的宽度,因此使文本正确地包装在下面。由于内容是动态的且图像宽度未知,因此还需要具有灵活性。
您可以在Firefox和Chrome中使用min-content来优雅地实现这一点。
.container {
/*Other style stuff up here*/
width: -moz-min-content;
width: -webkit-min-content;
}
以上的Jsfiddle - 在FF和Chrome中完美运行。
我的问题: Internet Explorer没有min-content(或我找到的等效项),这意味着文本而不是图像决定容器的宽度。
是否有任何同样优雅的方法可以在Internet Explorer中实现这一点?
如果没有,如何重新构建html/css以实现跨浏览器兼容性,以实现相同的功能?