jquery尺寸 位置大小-57

 

<!DOCTYPE html>
<html lang="en">
 
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./js/jquery.min.js"></script>
    <style>
        div {
            width: 100px;
            height: 100px;
            background-color: pink;
            border: 1px solid black;
            padding: 10px;
            margin: 15px;
        }
    </style>
</head>
 
<body>
    <div></div>
    <script>
        $(function() {
            //width
            console.log($("div").width());
            //("div").width(300);
            //innerwidth 加上padding
            console.log($("div").innerWidth());
            // 加上border
            console.log($("div").outerWidth());
            //加上margin
            console.log($("div").outerWidth(true));
        })
    </script>
</body>
 
</html>

运行结果

 

posted @ 2022-06-16 20:08  前端导师歌谣  阅读(23)  评论(0)    收藏  举报