IE6解决最小高度和最小宽度的问题

解决方法一:

div {

   height:auto !important;

   height:200px;

   min-height:200px;

}


解决方法二:

div {

   min-height:200px;

   _height:200px;

}

参考:技术分享 IE6不支持min-height的解决办法

http://developer.51cto.com/art/201008/220386.htm

IE6不支持min-height的解决办法

最小高度min-height是很有用的,但IE6却不支持。真烦人。有没有办法呢?

第一种方法:我们可以利用IE6不识别!important来实现: 

 
 
  1. height:auto!important;  
  2. height:500px;  
  3. min-height:500px;  
  4.  

这3句代码就让IE6也有了高度min-height的效果,大家可以把下面的代码复制保存成网页文件看看效果。

HTML代码 

 
 
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"   
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
  3.  <html xmlns="http://www.w3.org/1999/xhtml"> 
  4.  <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
  5.  <title>残缺 完美 生活</title>   
  6. </head>   
  7. <style type="text/css"> *{ margin:0; padding:0; }   
  8. body{ font-family:Arial, Helvetica,宋体,sans-serif; font-size:12px;   
  9.  
  10. text-align:center; background-color:#D4D5CC; }  
  11.  #wrapper{ height:auto!important;   
  12. height:500px; min-height:500px;  
  13.  width:760px; background-color:#e5e5e5; border:1px solid #fff;  
  14.  text-align:left; line-height:150%; padding:20px; margin:10px auto; }  
  15.  </style> <body> <div id="wrapper">   
  16. The Furthest Distance In The World <br /> 世界上最遥远的距离 <br />   
  17. Tagore泰戈尔 <br /> The furthest distance in the world <br />   
  18. 世界上最遥远的距离 <br /> Is not between life and death <br />   
  19. 不是生与死 <br /> But when I stand in front of you <br /> 
  20.  而是 我就站在你面前 <br /> Yet you don't know that I love you <br />   
  21. 你却不知道我爱你 <br />   
  22. </div> 
  23.  </body> 
  24.  </html> 
  25.  

[Ctrl+A全部选择提示:你可先修改部分代码,再按运行]

◆还有一种方法:在IE6IE5IE7FF测试竟然正常,而且能通过W3C检测的,方法如下:

HTML代码 

 
 
  1. #test { min-height:100px; background:#BBB; _height:100px; overflow: visible; } 红色部分应该不需要?
  2.  

[Ctrl+A全部选择提示:你可先修改部分代码,再按运行]

说明一下上面这段CSS的意思。

min-height:100px;这一句在ie7和FF已经可以正常显示了。。
_height:100px这一句在ie6,ie5测试显示正常。但不能过W3C验证:L
overflow:visible;这一句为了注明#test当内容超过100px时就自动延长。

注意:你必须保证#test以外的都要是overflow:visible。否则还是不会显示超出。



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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值