css实现ie6下最大,最小宽/高度

-、最大宽/高

IE6无法认读max-width,max-height属性,但IE支持自己javascript的属性表达,
例如
div{width:expression(250+"px")}和div{widt:250px}

在IE 的认读中都是一致的!

但是,如果在用户在浏览器禁用javascript,那么我们的写法就失败了。
所以,我们换种方式写,解决上面出现的失败现象。

* html div#division
width: expression( document.body.clientWidth > 776 ? "777px" : "auto" );
/* sets max-width for IE  为IE设置最宽值*/

max-width: 777px;/* this sets the max-width value for all standards-compliant browsers */
}

 

* html div#division {
   width: expression( document.body.clientWidth > (500/12) * parseInt(document.body.currentStyle.fontSize) ? "33em" : "auto" );
   max-width: 33em;
/* this sets the max-width value for all standards-compliant browsers */
}

 最小宽高可以用类似的方式实现,如下:

* html div#division {
   width: expression( document.body.clientWidth < 334 ? "333px" : "auto" );
/* set min-width for IE 为IE设置宽度最小值*/
   min-width: 333px;
/* sets min-width value for all standards-compliant browsers */
}

 

* html div#division {
   height: expression( this.scrollHeight > 332 ? "333px" : "auto" );
* sets max-height for IE 为IE设置高度最大值*/
   max-height: 333px;
/* sets max-height value for all standards-compliant browsers */
}

 

* html div#division {
   height: expression( this.scrollHeight < 334 ? "333px" : "auto" );
/* sets min-height for IE 为IE设置高度最小值*/
   min-height: 333px;
/* sets min-height value for all standards-compliant browsers */
}

二、最小宽/高虽然可以用上面的方法实现,但有更简单的方式

div#division {

  min-width:300px;

  width:auto!important;

  width:300px;

}

注意顺序不能更改

转载于:https://www.cnblogs.com/janey/archive/2009/12/29/1635092.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值