<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
}
body{
overflow: auto;
.box1 {
background: yellow;
position: sticky;
top: 0;
width: 100%;
/* height: 50px; */
.box2 {
height: 20px;
position: fixed;
top: 30px;
background: red;
.box3{
width: 60px;
height: 900px;
background: pink;
</style>
</head>
<body>
<div class="box1">暖暖</div>
<div class="box2"></div>
<div class="box3"></div>
</body>
</html>