<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>实现一屏一屏</title>
</head>
<style>
html,
body {
scroll-snap-type: y mandatory;//这个属性加在滚动内容的父级
height: 100vh;
overflow: auto;
margin: 0;
padding: 0;
}
div.item {
scroll-snap-align: center;//这个属性加在滚动内容上
height: 100vh;
font-size: 50px;
display: flex;
justify-content: center;
align-items: center;
}
</style>
<body>
<div style="background: aqua" class="item">
one
</div>
<div style="background: rebeccapurple" class="item">
two
</div>
<div style="background: greenyellow" class="item">
three
</div>
<div style="background: dimgrey" class="item">
four
</div>
</body>
</html>
css实现一屏一屏的效果
最新推荐文章于 2024-06-03 19:14:03 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)