当前位置: 首页 > 工具软件 > minmax.js > 使用案例 >

兼容解决方案: minMax

皮骏
2023-12-01
兼容解决方案: minMax

Min Max:

1. 方法:这个东西还是用JS解决吧,除min height CSS还不是那靠谱。
2.min-height:

.min-height:200px;height:auto;
_height:200px; /* hack for ie6 */

3.max Height

function setMaxHeight(elementId, height){
var container = document.getElementById(elementId);
container.style.height = (container.scrollHeight > (height - 1)) ? height + "px" : "auto";
}

4.min Width

function setMinWidth(elementId, width){
var container = document.getElementById(elementId);
container.style.width = (container.clientWidth < width) ? width + "px" : "auto";
}

5.max Width

function setMaxWidth(elementId, width){
var container = document.getElementById(elementId);
container.style.width = (container.clientWidth > (width - 1)) ? width + "px" : "auto";
}

转载于:https://www.cnblogs.com/wkylin/archive/2011/11/30/2269030.html

 类似资料: