php div 宽高,详解CSS控制div宽度最大宽度/高度和最小宽度/高度的方法

在网页制作中经常要控制p宽度最大宽度/高度或者最小宽度/高度,但是在IE6中很多朋友都会遇到不兼容的头疼问题,包括我也经常遇到这样的问题,在百度查了很多都没法解决,后来在一个论坛上学习到,在这里跟大家分享下css3样式代码,经过时间完全兼容各大主流浏览器。

* 最小寬度 */

.min_width{min-width:300px;

/* sets max-width for IE */

_width:expression(document.body.clientWidth < 300 ? "300px" : "auto");

}

/* 最大寬度 */

.max_width{

max-width:600px;

/* sets max-width for IE */

_width:expression(document.body.clientWidth > 600 ? "600px" : "auto");

}

/* 最小高度 */

.min_height{

min-height:200px;

/* sets min-height for IE */

_height:expression(this.scrollHeight < 200 ? "200px" : "auto");

}

/* 最大高度 */

.max_height{

max-height:400px;

/* sets max-height for IE */

_height:expression(this.scrollHeight > 400 ? "400px" : "auto");

}

/* 最大最小寬度 */

.min_and_max_width{

min-width:300px;

max-width:600px;

/* sets min-width & max-width for IE */

_width: expression(

document.body.clientWidth < 300 ? "300px" :

( document.body.clientWidth > 600 ? "600px" : "auto")

);

}

/* 最大最小高度 */

.min_and_max_height{

min-height:200px;

max-height:400px;

/* sets min-height & max-height for IE */

_height: expression(

this.scrollHeight < 200 ? "200px" :

( this.scrollHeight > 400 ? "400px" : "auto")

);

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值