flex布局滑动页面
html:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>flex</title> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <link rel="stylesheet" href="css/globel.css"> </head> <body> <div class="container"> <article> <section>1</section> <section>2</section> <section>3</section> <section>4</section> <section>5</section> <section>6</section> </article> </div> </body> </html>
css:
* { margin: 0; padding: 0; list-style: none; } html, body { width: 100%; height: 100%; overflow: hidden; } .container { width: 100%; height: 100%; } .container article { display: -webkit-box; display: -webkit-flex; display: flex; -wekit-box-orient: vertical; -webkit-flex-direction: column; flex-direction: column; -wekit-box-lines: single; -webkit-flex-wrap: nowrap; flex-wrap: nowrap; height: 100%; } .container article section { -webkit-flex: 1 0 auto; flex: 1 0 auto; width: 100%; height: 100%; background-color: #ccc; }