CSS ⟩ layout ⟩ top
top 隨著不同的 position 設定,而有不同的效果:
top
position
absolute or fixed: 自己上方 outer margin 到父容器上方的 inner border 的距離。
absolute
fixed
relative:自己 (從正常位置) 往下移動的距離。
relative
sticky: top property is used to compute the sticky-constraint rectangle.
sticky
static: top 無效果。
static
/* top: 父元素的 top 到自己的 top 的距離 */ top: 125%; /* 100% 代表父元素的高度 */
position: absolute 的定位子元素,它的 top, bottom, left, right 是相對於自己的最近定位父元素的。
CSS ⟩ top
anchor positioned elements
Last updated 6 months ago
Was this helpful?