·您当前的位置:首页 > 技术教程 > Html5技术 >

[html5]css控制div容器最小宽度最小高度的写法实例代码

时间:2017-07-14 18:22酷播
[html5]css控制div容器最小宽度最小高度的写法

[html5]css控制div容器最小宽度最小高度的写法

  1. * 最小寬度 */ 
  2. .min_width{min-width:300px; 
  3.    /* sets max-width for IE */ 
  4.    _width:expression(document.body.clientWidth < 300 ? "300px" : "auto"); 
  5. } 
  6.  
  7. /* 最大寬度 */ 
  8. .max_width{ 
  9.    max-width:600px; 
  10.    /* sets max-width for IE */ 
  11.    _width:expression(document.body.clientWidth > 600 ? "600px" : "auto"); 
  12. } 
  13.  
  14. /* 最小高度 */ 
  15. .min_height{ 
  16.    min-height:200px; 
  17.    /* sets min-height for IE */ 
  18.    _height:expression(this.scrollHeight < 200 ? "200px" : "auto"); 
  19. } 
  20.  
  21. /* 最大高度 */ 
  22. .max_height{ 
  23.    max-height:400px; 
  24.    /* sets max-height for IE */ 
  25.    _height:expression(this.scrollHeight > 400 ? "400px" : "auto"); 
  26. } 
  27.  
  28. /* 最大最小寬度 */ 
  29. .min_and_max_width{ 
  30.    min-width:300px; 
  31.    max-width:600px; 
  32.    /* sets min-width & max-width for IE */ 
  33.    _width: expression( 
  34.       document.body.clientWidth < 300 ? "300px" : 
  35.         ( document.body.clientWidth > 600 ? "600px" : "auto") 
  36.    ); 
  37. } 
  38.  
  39. /* 最大最小高度 */ 
  40. .min_and_max_height{ 
  41.    min-height:200px; 
  42.    max-height:400px; 
  43.    /* sets min-height & max-height for IE */ 
  44.    _height: expression( 
  45.       this.scrollHeight < 200 ? "200px" : 
  46.         ( this.scrollHeight > 400 ? "400px" : "auto") 
  47.    ); 
  48. } 

 

热门文章推荐

请稍候...

保利威视云平台-轻松实现点播直播视频应用

酷播云数据统计分析跨平台播放器