
如果你想固定高度,设置width(宽度)height(高度)display:block(成块) float:left(左浮动)和 overflow:hidden(禁止溢出)属性。应该就可以了
超出固定高度显示滚动条,只要设置style属性中的overflowY="scroll";
documentgetElementById('scroll')styleoverflowY="scroll";
获取div的高度,如果获取不到,可用下面的方法,一下方法是获取div的编辑完成后的高度:
/
obj:需要获取属性的html对象
prop:需要获取的obj对象的属性
/
function getCurrentStyle (obj, prop) {
if (objcurrentStyle) {
return objcurrentStyle[prop];
}
else if (windowgetComputedStyle) {
propprop = propreplace (/([A-Z])/g, "-$1");
propprop = proptoLowerCase ();
return documentdefaultViewgetComputedStyle (obj,null)[prop];
}
return null;
}
var div = documentgetElementsByTagName("div")[0];
var height = getCurrentStyle(div,"height");
用jQuery
$('div')offset()top 是浏览器顶部距离
$("div")width(); div宽度
$("div")html() 内容
//获取id="div"的高度
documentgetElementById("div")styleheight//设置id="div"的高度
documentgetElementById("div")styleheight="200px";
以上就是关于div 没有设置height 内容撑大···怎么获取高度啊, clientHeight offsetHeight style.height 都不行全部的内容,包括:div 没有设置height 内容撑大···怎么获取高度啊, clientHeight offsetHeight style.height 都不行、js判断div高度。、如何获取div距离浏览器顶部的高度,宽度,内容等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)