zoukankan      html  css  js  c++  java
  • css吸顶效果

    <template>
      <div id="Furong">
        <div class="tab-control">
          <div v-for="(item, index) in titles" class="tab-control-item" :class="{active: isActive == index}"
            @click="onClick(index)">
            <span>{{item}}</span>
          </div>
        </div>
      </div>
    </template>
    
    <script>
      export default {
        name: 'Furong',
        data() {
          return {
            msg: 'hello furong!',
            titles: ['流行', '新款', '精选'],
            isActive: 0
          }
        },
        methods: {
          onClick(index) {
            console.log("onClick");
            this.isActive = index;
          }
        }
      }
    </script>
    
    <style>
      .tab-control {
        display: flex;
        background-color: orange;
      }
    
      .tab-control-item {
        flex: 1;
        height: 40px;
        line-height: 40px;
      }
    
      .active {
        color: orangered;
      }
    
      .tab-control-item>span {
        padding: 5px;
      }
    
      .active>span {
        border-bottom: 3px solid orangered;
      }
    
      /* 吸顶 */
      #Furong {
        position: sticky;
        top: 0;
      }
    </style>
    

    注:
    移动端可以直接使用,有的浏览器不支持

  • 相关阅读:
    PKU1008
    PKU 1007
    PKU 3983
    PKU 1005
    PKU1004
    PKU 1003解题
    new.target
    debugger 关键字
    React 高阶组件
    CSS|规范
  • 原文地址:https://www.cnblogs.com/zhangxuechao/p/15029495.html
Copyright © 2011-2022 走看看