开发者

CSS max-width: 100% for IE 6 with expression?

开发者 https://www.devze.com 2023-03-17 18:25 出处:网络
I have this css: .container img { max-width: 100% !important; height: auto; } Now I need this working for IE 6.

I have this css:

.container img {
    max-width: 100% !important;
    height: auto;
 }

Now I need this working for IE 6.

I know you can do:

 width: expression(this.width > xxx ? xx : true);

but xxx needs to be a number, not a percentage I believe.

I'm doing max-width: 100% so that the width of the 开发者_运维问答image will not exceed the width of the .container

Any ideas?

Thanks.


Without having tested it, I guess you need to compare the elements (client) width to its parent's. Something like:

width: expression(this.clientWidth > this.parentNode.clientWidth ? this.parentNode.clientWidth + "px" : this.clientWidth + "px");
0

精彩评论

暂无评论...
验证码 换一张
取 消