Home  >  Article  >  Web Front-end  >  CSS设置div的最小高度和最小宽_html/css_WEB-ITnose

CSS设置div的最小高度和最小宽_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:37:311573browse

CSS设置div的最小高度和最小宽度:

所谓设置div的最小高度和宽度就是设置一个值,如果实际宽度或者高度小于此值时,就会将实际的宽度和高度值设置为规定的此最小值,下面就通过实例代码简单做一下介绍。

如果在标准浏览器中,当然可以使用max-height或者max-width实现此效果,例如:

max-width:50px;max-height:100px;

以上代码在标准浏览器中是没有任何问题的,但是无奈IE6浏览器并不支持,因为当前还有为数不少的IE6用户,所以需要兼容IE浏览器。代码修改如下:

max-width:50px;max-height:100px; width:expression(document.body.clientWidth<50?"50px":"auto"); height:expression(document.body.clientWidth<100?"100px":"auto");

原文地址是:http://www.51texiao.cn/div_cssjiaocheng/2015/0606/3421.html

最为原始地址是:http://www.softwhy.com/forum.php?mod=viewthread&tid=9656

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn