获取元素的内部高度 [英] Getting an element's inner height

查看:118
本文介绍了获取元素的内部高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取元素的内部高度,而不需要填充和边框?



没有jQuery,纯粹的JS和跨浏览器解决方案(包括IE7)



解决方案

pre> var style = window.getComputedStyle(document.getElementById(Example),null);
style.getPropertyValue(height);

上述版本将适用于现代浏览器。请检查IE浏览器的 currentStyle


How do you get an element's inner height, without padding and borders?

No jQuery, just pure JS, and a cross-browser solution (IE7 included)

解决方案

var style = window.getComputedStyle(document.getElementById("Example"), null);
style.getPropertyValue("height");

The above version will work in modern browsers. Please check currentStyle for IE browsers.

这篇关于获取元素的内部高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆