css3 header.sticky,css中sticky属性

sticky粘性定位

是css新增属性

其实就是以往我们做的fixed;当滚动条下拉到一定程度设置容器为fixed;

用图来演示:

275c408a6565d504d94cbf82d09012f9.gif

常见场景:通讯录及头部工具条

Document

html{background:#f5f5f5;}

body{min-height: 1280px;max-width: 640px;margin:0 auto;background:#fff;}

*{margin:0;padding:0;}

.nav{color: #fff;font-size: 24pt;padding:0 10px; position: sticky; top: 0px;height: 50px;background: #067;}

p{line-height: 2; }

A

Keeps elements positioned as "fixed" or "relative" depending on how it appears in the viewport. As a result the element is "stuck" when necessary while scrolling.

B

Keeps elements positioned as "fixed" or "relative" depending on how it appears in the viewport. As a result the element is "stuck" when necessary while scrolling.

C

Keeps elements positioned as "fixed" or "relative" depending on how it appears in the viewport. As a result the element is "stuck" when necessary while scrolling.

D

Keeps elements positioned as "fixed" or "relative" depending on how it appears in the viewport. As a result the element is "stuck" when necessary while scrolling.

兼容情况

af7cbb09db9572b9fbe27a67b7cc129c.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值