简体   繁体   English

获取HTML元素的完整大小的正确方法是什么

[英]What is the correct way to get the full size of an HTML element

In HTML, the actual height of an element is 在HTML中,元素的实际高度为

actualheight = height + top border + top margin + top padding + bottom margin + bottom border + bottom padding. actualheight = height + top border + top margin + top padding + bottom margin + bottom border + bottom padding。

Is there a way to get this in JQuery? 有没有办法在JQuery中获得这个?

Crap you said height , not width, I'll leave my width answer here for reference anyway. 废话你说高度 ,而不是宽度,我会留下我的宽度答案在这里作为参考无论如何。
This page explains how to do it with height. 本页介绍了如何使用高度进行操作。

.outerWidth() - Get the current computed width for the first element in the set of matched elements, including padding and border . .outerWidth() - 获取匹配元素集中第一个元素的当前计算宽度, 包括填充和边框

.innerWidth() - Get the current computed width for the first element in the set of matched elements, including padding but not border . .innerWidth() - 获取匹配元素集中第一个元素的当前计算宽度, 包括填充但不包括边框

.width() - Get the current computed width for the first element in the set of matched elements. .width() - 获取匹配元素集中第一个元素的当前计算宽度

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM