/* 示例代码:CSS position 属性的使用 */
/* static (默认值) */
.static {
position: static;
}
/* relative */
.relative {
position: relative;
top: 20px; /* 相对于自身原来的位置偏移 */
left: 10px;
}
/* absolute */
.absolute {
position: absolute;
top: 50px; /* 相对于最近的非 static 定位祖先元素偏移 */
right: 0;
}
/* fixed */
.fixed {
position: fixed;
bottom: 0; /* 固定在视口底部 */
right: 0;
}
/* sticky */
.sticky {
position: sticky;
top: 10px; /* 当滚动到指定位置时,变为固定定位 */
}
top
、bottom
、left
、right
等属性的影响。static
定位的祖先元素进行定位。如果没有这样的祖先元素,则相对于初始包含块(通常是浏览器窗口)。上一篇:css3动画属性有哪些
下一篇:css两行省略号
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站