The difference between fixed and absolute of postion in css

I have not particularly understood the several positioning methods of positon, record it

fixed
positioning, the reference position is the upper left corner of the browser window, that is, the coordinate point is (0px, 0px)

absolute
absolute positioning, exhibitors from the position of the current element is positioned closest to the way fixed, absolute, top-left corner of the ancestors of the principle of relative, for example

<div style="posistion:relative" id="p1">
    <div style="posistion:fixed" id="p2">
        <div style="position:static" id="p3">
            <h2 style="postion:absolute;left:10px;top:10px">我的参照坐标是id=p2</h2>
        </div>
    </div>
</div>

Through the above example, it can be seen that the absolute positioning reference point of h2 is the parent element of id = p2, p3 is a static static positioning, and cannot be used as an positioning point

Guess you like

Origin www.cnblogs.com/baimeishaoxia/p/12683750.html