需求:子元素固定在父容器底部。父層 position: relative 建立定位基準,子層 position: absolute; bottom: 0; left: 0; width: 100%; text-align: center;。
<div style="position:relative; height:100px; width:100px; border:1px solid red">
<div style="position:absolute; bottom:0; left:0; width:100px; text-align:center;">
<img src="***.gif" width="20" height="20">
</div>
</div>
height 或 min-height,否則高度塌陷導致底部定位失效。left:0; width:100% 確保子元素橫向撐滿,配合 text-align:center 實現內容水平置中。vertical-align:middle 於父層 line-height 等高法也可,但 absolute 更靈活支援複雜內容。