分享 Bootstrap 中为 img 元素设置 max-width 所引起的浮动问题解决

mingyuan0715 · May 15, 2013 · 3427 hits

案例如下

<div style="float:right">
  <img></img>
  <a>其他行内元素</a> 
</div>

bootstrap 默认设置 img 的max-width:100%; 这个时候的 IE8 及以下浏览器对于行内元素的宽度计算比较复杂,会发生折行的问题。 具体可见这篇文章:http://jiataodong.blog.163.com/blog/static/3490549220110246154744/

我的解决办法,拓展 bootstrap 的 css

.pull-right img {
  max-width: 940px;
}

我网站的最大宽度也就是 940px,只要不是默认的 100% 就哦了。

No Reply at the moment.
You need to Sign in before reply, if you don't have an account, please Sign up first.