美文网首页
移动端如何实现仿今日头条似的横向滚动导杭栏效果

移动端如何实现仿今日头条似的横向滚动导杭栏效果

作者: 南漂一枚 | 来源:发表于2020-08-12 08:57 被阅读0次

https://www.cnblogs.com/jpwz/p/12691810.html

<template>

  <div class="container">

    <div class="head">

      <img class="left" src="../../assets/img/back.png" alt />

      <span class="center">全部照片</span>

      <img class="right" src="../../assets/img/picture-li1.png" />

    </div>

    <!-- <ul class="tab"><li>VR(1)</li><li>主卧(1)</li><li>厨房(1)</li><li>卧室A(1)</li><li>阳台A(1)</li><li>客厅(1)</li></ul> -->

    <div class="nav">

      <a href="#">关注</a>

      <a href="#">推荐</a>

      <a href="#">新闻</a>

      <a href="#">社会</a>

      <a href="#">国际</a>

      <a href="#">军事</a>

      <a href="#">娱乐</a>

      <a href="#">三农</a>

      <a href="#">直播</a>

      <a href="#">小视频</a>

      <a href="#">问答</a>

      <a href="#">体育</a>

      <a href="#">科技</a>

    </div>

    <div>

      正文

      <br />正文

      <br />正文

      <br />正文

      <br />正文

      <br />

    </div>

  </div>

</template>

<style lang="scss" scoped>

.container {

  display: flex;

  flex-direction: column;

  justify-content: flex-start;

  align-items: center;

  background-color: black;

  .head {

    height: 70px;

    width: 100%;

    // border: hotpink solid 1px;

    display: flex;

    flex-direction: row;

    justify-content: space-between;

    align-items: center;

    .left {

      display: inline-block;

      width: 24px;

      height: 40px;

      margin-left: 34px;

    }

    .right {

      display: inline-block;

      width: 40px;

      height: 40px;

      margin-right: 34px;

      // border: springgreen solid 1px;

    }

  }

  .nav {

    width: 100%;

    height: 50px;

    line-height: 50px;

    /*段落中文本不换行*/

    white-space: nowrap;

    /*阴影*/

    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);

    /*设置横向滚动*/

    overflow-x: scroll;

    /*禁止纵向滚动*/

    overflow-y: hidden;

    /*文本平铺*/

    text-align: justify;

    /*背景颜色*/

    background: #f4f5f6;

    padding: 0px 5px;

    margin-bottom: 10px;

    /*设置边距改变效果为内缩*/

    box-sizing: border-box;

  }

  .nav a {

    color: #505050;

    /*取消超链接下划线*/

    text-decoration: none;

    margin: auto 10px;

  }

  .nav::-webkit-scrollbar {

    /*隐藏滚动条*/

    display: none;

  }

}

</style>

相关文章