zoukankan      html  css  js  c++  java
  • vue 横向导航滚动 光标移动动画


    <template> <div class="nav_wrapper"> <div ref="navContainer" class="nav_container"> <div class="nav_item" v-on:click="onClick(item)" v-for="(item,index) in Navs" :key="index"> {{item.title}} </div> <div class="nav_footer_cursor" :style="{ Num, left:Left }" ></div> </div> </div> </template>

      

    <script>
    import {mapState} from "vuex";
    export default {
        data(){
            return{
                Left:"10px",
                Num:"64px"
            }
        },
        computed:mapState({
            Navs:"Navs"//这是拿到的导航列表
        }),
        methods:{
            onClick(obj){
                let num=window.event.target.offsetWidth;
                let positionNum=window.event.target.offsetLeft;
                // window.console.log(positionNum)
                this.Num=num+"px";
                this.Left=positionNum+"px";
                this.$store.dispatch("SortGoods",obj)
            }
        }
    }
    </script>
    

      

    <style scoped>
    .nav_wrapper
    {
        100%;
        height:40px;
        margin-top:64px;
    }
    .nav_item
    {
        100px;
        height:40px;
        text-align: center;
        white-space: nowrap;
        padding:0 10px;
    }
    .nav_container::-webkit-scrollbar{
        display: none;
    }
    .nav_container
    {
        100%;
        display: flex;
        position: relative;
        overflow: scroll;
        white-space: nowrap;
    }
    .nav_footer_cursor
    {
        100%;
        height:3px;
        border-radius:3px;
        background: red;
        position: absolute;
        margin-top:20px;
        transition: all 0.3s linear 0.1s;
    }
    </style>
    

      

  • 相关阅读:
    动手动脑之异常处理
    git一些概念
    jquery each函数使用
    数据库客户端
    plotly.js
    网站跳转汇总
    jquery 实现间隔运行
    学习 在线调试
    Robot限制字典的key大写的class
    Gerrit 相关
  • 原文地址:https://www.cnblogs.com/xiaobu-wu/p/12851761.html
Copyright © 2011-2022 走看看