/* Sticky CSS Example */
.sticky {
position: -webkit-sticky; /* For Safari */
position: sticky;
top: 0; /* Specifies the distance from the top of the container when the element becomes fixed */
}
/* Explanation:
- The `position: sticky;` property is a hybrid between relative and fixed positioning.
- An element with `position: sticky;` is treated as relatively positioned until it crosses a specified threshold (top, bottom, left, or right).
- Once the threshold is crossed, the element becomes fixed (sticks to its position) until it reaches the end of its parent container or another threshold.
- In this example, the element will stick to the top of the viewport when you scroll past it.
*/
上一篇:css左浮动
下一篇:文字居中css
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站