完整 CSS 代码
- header{
- position: sticky;
- background: #fff;
- top: 0;
- font-size: 20px;
- padding: 10px;
- z-index: 1;
- }
- shadow::before{
- content: '';
- box-shadow: 0 0 10px 1px #333;
- position: fixed;
- width: 100%;
- }
- shadow::after{
- content: '';
- width: 100%;
- height: 30px;
- background: linear-gradient(to bottom, #fff 50% , transparent);
- position: absolute;
- }
HTML 结构也很简单
- <header>LOGO</header>
- <shadow></shadow>
- <main>很多内容文本</main>