Skip to content

CSS position 的定位详解 #36

@vst-h

Description

@vst-h

1、position 可填写的值

  • static,默认值,遵循正常的文档流。没有任何定位效果,偏移属性 (top/left/z-index) 无效

  • relative,元素相对于它在正常流中的原始位置进行偏移。原始文档空间不变

  • absolute,元素相对于其最近的已定位祖先容器进行定位。脱离文档流。

  • fixed,元素相对于页面视口(viewport)进行定位。脱离文档流。不随页面滚动而改变。

  • sticky,元素表现为 relative,直到滚动达到页面视口阈值后表现为 fixed。填写偏移属性才生效。

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions