HTML
position 改變物件的位置 sets how an element is positioned in a document position: static | relative | fixed | absolute | sticky static:靜態定位 relative:相對定位 fixed:固定定位 absolute:絕對定位 sticky:黏貼定位
<style> #div1 {position:fixed ; top:10px ; left:10px; } #div2 {position:fixed; top:10px ; right:10px; } #div3 {position:fixed ; bottom:10px ; left:10px; } #div4 {position:absolute ; bottom:10px ; right:10px; } </style>
<div class="outerDiv">outerDiv <div class="innerDiv"> innerDiv</div> </div> <style> .outerDiv { position: relative; } .innerDiv { position: absolute; bottom: 10px; right: 10px; } </style>
<div class="outerDiv">outerDiv <div class="innerDiv"> innerDiv</div> </div> <style> .outerDiv { position: relative ; } .innerDiv { position: sticky; } </style>