jQuery 中的宽度、内部宽度和外部宽度、高度、内部高度和外部高度有什么区别 [英] What is difference between width, innerWidth and outerWidth, height, innerHeight and outerHeight in jQuery

查看:33
本文介绍了jQuery 中的宽度、内部宽度和外部宽度、高度、内部高度和外部高度有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

<头><script type="text/javascript" src="jquery.js"></script><script type="text/javascript">$(document).ready(function(){var div = $('.test');var 宽度 = div.width();//200 像素varinnerWidth = div.innerWidth();//200 像素var 外宽度 = div.outerWidth();//200 像素var 高度 = div.height();//150 像素varinnerHeight = div.innerHeight();//150 像素var 外层高度 = div.outerHeight();//150 像素});<style type="text/css">.测试{宽度:200px;高度:150px;背景:黑色;}</风格><身体><div class="test"></div>

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

谢谢.

解决方案

你看到这些例子了吗?看起来和你的问题很相似.

jQuery:高度、宽度、内部和外部

I wrote some example to see what is the difference, but they display me same results for width and height.

<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>

In this example you can see that they output same results. If anyone know what is the difference please show me appropriate answer.

Thanks.

解决方案

Did you see these examples? Looks similar to your question.

Working with widths and heights

jQuery - Dimensions

jQuery: height, width, inner and outer

这篇关于jQuery 中的宽度、内部宽度和外部宽度、高度、内部高度和外部高度有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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