/* 1. static */
/* 默认值,元素按照正常的文档流进行布局,不会受到 top, bottom, left, right 的影响。 */
div {
position: static;
}
/* 2. relative */
/* 相对定位,元素相对于其正常位置进行偏移,但仍然占据原来的空间。 */
div {
position: relative;
top: 20px;
left: 10px;
}
/* 3. absolute */
/* 绝对定位,元素相对于最近的已定位(非 static)祖先元素进行定位,如果不存在这样的祖先,则相对于初始包含块(通常是视口)。 */
div {
position: absolute;
top: 50px;
left: 50px;
}
/* 4. fixed */
/* 固定定位,元素相对于浏览器窗口进行定位,滚动页面时元素位置不变。 */
div {
position: fixed;
bottom: 0;
right: 0;
}
/* 5. sticky */
/* 粘性定位,元素在跨越特定阈值前为相对定位,之后为固定定位。通常与 top, bottom, left, right 一起使用。 */
div {
position: sticky;
top: 10px;
}
上一篇:css设置背景图片大小
下一篇:css 禁止点击
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站