您好,欢迎访问一九零五行业门户网

js里取容器大小、定位、距离等属性搜集整理_javascript技巧

element.clientwidth //元素的实际宽度,不算边框
element.clientheight//元素的实际高度,不算边框
element.offsetwidth //元素的实际宽度,加上边框
element.offsetheight//元素的实际高度,加上边框
element.scrollwidth//这个说法很多,我测试下来应该是元素实际宽度-滚动条的宽度
element.scrollheight//这个说法很多,我测试下来应该是元素实际高度-滚动条的高度
element.offsetleft //相对于父对象的距离,ie下如果position设为relative,则是相对于window的距离
element.offsettop //相对于父对象的距离,ie下如果position设为relative,则是相对于window的距离
window.screenleft //当前窗口距离屏幕距离 only for ie
window.screenx //当前窗口距离屏幕距离 not for ie
window.innerwidth//当前窗口大小(内)not for ie
window.outerwidth//当前窗口大小(外)not for ie
window.screen.width //当前屏幕分辨率
window.screen.availwidth //当前屏幕可用分辨率
其它类似信息

推荐信息