zoukankan      html  css  js  c++  java
  • 移动端实现fixed定位的导航栏选项横向滑动

    移动端的导航栏需要滑动到一定距离,固定在页面顶部(即fixed定位),此时要让导航栏内的选项卡横向滑动,

    效果如图

    代码如下

    <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8">
      <title>Document</title>
      <style>
        .box {
           90%;
          margin: 50px auto;
          border: 1px solid #ddd;
          display: flex;
          flex-wrap: nowrap;
          overflow-x: scroll;
        }
        .box>div {
           400px;
          height: 50px;
          flex-shrink: 0;
        }
        .item1 {
          background-color: #aff;
        }
        .item2 {
          background-color: #afa;
        }
        .item3 {
          background-color: #faf;
        }
        .item4 {
          background-color: #ffa;
        }
      </style>
    </head>
    <body>
      <div class="box">
        <div class="item1"></div>
        <div class="item2"></div>
        <div class="item3"></div>
        <div class="item4"></div>
      </div>
    </body>
    </html>
    

    核心代码

    .box {
      display: flex;
      flex-wrap: nowrap;
    }
    .box>div {
      flex-shrink: 0;
    }
    
  • 相关阅读:
    hdu 1542 Atlantis
    cf C. Cupboard and Balloons
    cf C. Tourist Problem
    hdu 4027 Can you answer these queries?
    hdu 1255 覆盖的面积
    hdu 1698 Just a Hook
    zoj 1610 Count the Colors
    hdu 4302 Holedox Eating
    hdu 4288 Coder
    tsne理论学习
  • 原文地址:https://www.cnblogs.com/ZerlinM/p/13529169.html
Copyright © 2011-2022 走看看