gpt4 book ai didi

javascript - jQuery中的宽度,innerWidth和outerWidth,height,innerHeight和outerHeight有什么区别

转载 作者:IT王子 更新时间:2023-10-29 02:40:30 25 4
gpt4 key购买 nike

我写了一些例子来看看有什么区别,但它们显示的宽度和高度的结果相同。

<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var div = $('.test');
var width = div.width(); // 200 px
var innerWidth = div.innerWidth(); // 200px
var outerWidth = div.outerWidth(); // 200px

var height = div.height(); // 150 px
var innerHeight = div.innerHeight(); // 150 px
var outerHeight = div.outerHeight(); // 150 px
});

</script>
<style type="text/css">
.test
{
width: 200px;
height: 150px;
background: black;
}
</style>
</head>
<body>
<div class="test"></div>
</body>
</html>

在此示例中,您可以看到它们输出相同的结果。如果有人知道有什么区别,请告诉我适当的答案。

谢谢。

最佳答案

你看到这些例子了吗?看起来与您的问题相似。

Working with widths and heights

enter image description here

jQuery - Dimensions

jQuery: height, width, inner and outer

关于javascript - jQuery中的宽度,innerWidth和outerWidth,height,innerHeight和outerHeight有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17845027/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com