ie6不支持最大高度,可以使用css表达式或者js来实现,但考虑到css表达式太影响性能就不用考虑了,下面给出js解决方案
//直接操作需要的元素
var container = document.getElementById('container');
container.style.height = (container.scrollHeight > 199) ? "200px" : "auto";
//定义函数,多次调用
function setMaxHeight(elementId, height){
var container = document.getElementById(elementId);
container.style.height = (container.scrollHeight > (height - 1)) ? height + "px" : "auto";
}
//调用函数
setMaxHeight('container1', 200);
setMaxHeight('container2', 500);