移动端轮播图
Posted 前端精髓
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了移动端轮播图相关的知识,希望对你有一定的参考价值。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
}
html,
body {
width: 100%;
height: 100%;
}
::-webkit-scrollbar {
display: none;
}
.container {
display: flex;
overflow: auto;
outline: 1px dashed lightgray;
scroll-snap-type: x mandatory;
width: 100%;
height: 128px;
flex-flow: row nowrap;
}
.item {
line-height: 128px;
font-size: 64px;
width: 100%;
height: 128px;
text-align: center;
scroll-snap-align: center;
flex: none;
}
</style>
</head>
<body>
<div class="container x mandatory-scroll-snapping" dir="ltr">
<div class="item" style="background: red;">X Mand. LTR</div>
<div class="item" style="background: blue">2</div>
<div class="item" style="background: pink">3</div>
<div class="item" style="background: green">4</div>
<div class="item" style="background: yellow">5</div>
</div>
</body>
</html>
了解scroll-snap-type:https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-snap-type
以上是关于移动端轮播图的主要内容,如果未能解决你的问题,请参考以下文章