在IE浏览器中模拟实现图片CSS的 max-width

非IE浏览器:

.post-body img {max-width:400px;}

IE:

.post-body img {
max-width:400px;
width: expression(this.width > 400 ? 400: true);
}

非IE浏览器:

.post-body img {max-width:95%;}

IE:

无法实现百分比的最大值

特别说明:

如果图片放在一个容器中时, 即使设置了容器的max-width值, 也需要设置图片的max-width值, 否则图片还是会撑开容器的尺寸.

#sidebar {width:220px;
width: expression(this.width > 220 ? 220: true);
}

#sidebar img {max-width:200px;
width: expression(this.width > 200 ? 200: true);
}

来源: http://phydeaux3.blogspot.com/2006/01/max-width-and-faking-it-for-ie.html

发表评论

电子邮件地址不会被公开。

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>