☀【offset()/position()】

6144 단어 position
<!DOCTYPE html>

<html lang="zh-CN">

<head>

    <meta charset="utf-8">

    <title></title>

</head>

<body>

    <div id="box">box</div>

    <script src="http://static01.baomihua.com/js/lib/jquery-1.4.4.min.js?t=20120926.js"></script>

    <script>

        /*

         * position()           —     ,   position: relative;               —   。                ,             

         * offset()               

         */

        console.log($('#box').offset())

    </script>

    <style>

        #box {

            width: 100px;

            height: 100px;

            background-color: #F00;

            position: absolute;

            top: 100px;

            left: 100px;

        }

    </style>

    <script>

        console.log($('#box').offset()) //            

    </script>

</body>

</html>

좋은 웹페이지 즐겨찾기