zoukankan      html  css  js  c++  java
  • vue基于 element-ui 实现菜单动画效果,任意添加 li 个数均匀撑满 ul 宽度

    鼠标移至图标上时使用toolTip显示对应的中文提示文字

    <template>

    <div class="em_tool">
    <win :id="win.id" :data="win">
    <div class="nav">
    <input type="checkbox" class="nav__cb" id="menu-cb">
    <div class="nav__content">
    <ul class="nav__items" id="subnav">
    <li v-for="(item,key) in tool" class="nav__item">
    <!-- <span class="nav__item-text" prefix-icon="el-icon-users">{{item}}</span>-->
    <el-tooltip class="item" placement="top-start">
    <div slot="content">{{item.value}}</div>
    <el-button :ref="item.id" :icon="item.icon" class="nav__item-text" @click="fn(item,key)"></el-button>
    </el-tooltip>
    </li>
    </ul>
    </div>
    <label class="nav__btn" for="menu-cb"></label>
    </div>
    </win>
    </div>
    </template>

    <script>
    export default {
    name: "em_tools",
    components: {
    win
    },
    data() {
    return {
    win: {
    id: "em_tool",
    title: "",
    top: "86%",
    show: true,
    width: 450,
    resizable: false,
    class: "em-tool-window"
    },
    input: '',
    tool: [
    {id:"tool_flyToScene",value: "menu1", icon: "el-icon-scene",control_id:"scene",fn:"toScene",trigger:"none"},
    {id:"tool_transparent",value: "menu2", icon: "el-icon-transparent",control_id:"em_slider",fn:"showFn",trigger:true},
    {id:"tool_coordinates",value: "menu3", icon: "el-icon-coordinates",control_id:"scene",fn:"xyz",trigger:true},
    {id:"tool_data",value: "menu4", icon: "el-icon-data",control_id:"scene",fn:"scene_data",trigger:true},
    {id:"tool_distance",value: "menu5", icon: "el-icon-distance",control_id:"scene",fn:"measure_drawLine",trigger:"none"},
    {id:"tool_area",value: "menu6", icon: "el-icon-area",control_id:"scene",fn:"measure_drawPloy",trigger:"none"},
    {id:"tool_hightly",value: "menu7", icon: "el-icon-hightly",control_id:"scene",fn:"",trigger:"none"},
    {id:"tool_label",value: "menu8", icon: "el-icon-label",control_id:"scene",fn:"measure_clear",trigger:"none"}......
    ]
    }
    },
    created() {
    var bodywidth = Number(document.body.clientWidth);
    var bodyheight = Number(document.body.clientHeight);
    console.log(bodywidth);
    this.win.left = bodywidth - 450;
    /*this.win.top=bodyheight-130;*/

    },
    mounted(){
    var subnav = document.getElementById('subnav'),
    aLi = document.querySelectorAll('#subnav li'),
    w = parseFloat(subnav.offsetWidth / aLi.length);//通过ul的宽度除以li的个数来计算每个li的宽度
    console.log("个数:"+aLi.length);
    for(var i=0;i<aLi.length;i++){
    aLi[i].style.width = w + 'px';
    }
    },
    methods: {

    }
    }
    </script>

    <style lang="scss" scoped>
    @import "em_tools";
    </style>

    style部分
    nav__item-text*, *:before, *:after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    }
    .nav {
    overflow: hidden;
    float: right;
    right: 20px;
    bottom: 70px;
    width: auto;
    height: 60px;
    //background:linear-gradient(rgba(216, 187, 55, 0.8),rgba(20, 31, 55, 0.5));
    border-radius: 5px;
    -webkit-transform: translate3d(1%, 0, 0);
    transform: translate3d(1%, 0, 0);
    box-shadow: 0 10px 35px rgba(0, 0, 0, 0.2);
    }
    .nav__cb {
    z-index: -1000;
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0;
    pointer-events: none;
    }
    .nav__content {
    position: relative;
    width: 60px;
    height: 100%;
    -webkit-transition: width 1s cubic-bezier(0.49, -0.3, 0.68, 1.23);
    transition: width 1s cubic-bezier(0.49, -0.3, 0.68, 1.23);
    }
    .nav__cb:checked ~ .nav__content {
    -webkit-transition: width 1s cubic-bezier(0.48, 0.43, 0.29, 1.3);
    transition: width 1s cubic-bezier(0.48, 0.43, 0.29, 1.3);
    background: url(../../assets/image/tool.bg2.png) no-repeat;
    width: 450px;
    }
    .nav__items {
    display: inline-flex;
    position: relative;
    width: 450px;
    height: 100%;
    padding-right: 45px;
    padding-left: 25px;
    list-style-type: none;
    font-size: 0;
    }
    .nav__item {
    display: inline-block;
    vertical-align: top;
    text-align: center;
    color: #bbb;
    font-size: 14px;
    line-height: 60px;
    font-family: Helvetica, Arial, sans-serif;
    font-weight: bold;
    -webkit-perspective: 1000px;
    perspective: 1000px;
    -webkit-transition: color 0.3s;
    transition: color 0.3s;
    cursor: pointer;
    }
    .nav__item:hover {
    color: #fff;
    }
    .nav__item-text {
    display: block;
    height: 100%;
    -webkit-transform: rotateY(-70deg);
    transform: rotateY(-70deg);
    opacity: 0;
    -webkit-transition: opacity 0.7s, -webkit-transform 0.7s cubic-bezier(0.48, 0.43, 0.7, 2.5);
    transition: opacity 0.7s, -webkit-transform 0.7s cubic-bezier(0.48, 0.43, 0.7, 2.5);
    transition: transform 0.7s cubic-bezier(0.48, 0.43, 0.7, 2.5), opacity 0.7s;
    transition: transform 0.7s cubic-bezier(0.48, 0.43, 0.7, 2.5), opacity 0.7s, -webkit-transform 0.7s cubic-bezier(0.48, 0.43, 0.7, 2.5);
    }

    .nav__cb:checked ~ .nav__content .nav__item-text {
    -webkit-transform: rotateY(0);
    transform: rotateY(0);
    opacity: 1;
    -webkit-transition: opacity 0.2s, -webkit-transform 0.7s cubic-bezier(0.48, 0.43, 0.7, 2.5);
    transition: opacity 0.2s, -webkit-transform 0.7s cubic-bezier(0.48, 0.43, 0.7, 2.5);
    transition: transform 0.7s cubic-bezier(0.48, 0.43, 0.7, 2.5), opacity 0.2s;
    transition: transform 0.7s cubic-bezier(0.48, 0.43, 0.7, 2.5), opacity 0.2s, -webkit-transform 0.7s cubic-bezier(0.48, 0.43, 0.7, 2.5);
    }
    .nav__item:nth-child(1) .nav__item-text {
    -webkit-transition-delay: 0.7s;
    transition-delay: 0.7s;
    }
    .nav__cb:checked ~ .nav__content .nav__item:nth-child(1) .nav__item-text {
    -webkit-transition-delay: 0s;
    transition-delay: 0s;
    }
    .nav__item:nth-child(2) .nav__item-text {
    -webkit-transition-delay: 0.6s;
    transition-delay: 0.6s;
    }
    .nav__cb:checked ~ .nav__content .nav__item:nth-child(2) .nav__item-text {
    -webkit-transition-delay: 0.1s;
    transition-delay: 0.1s;
    }
    .nav__item:nth-child(3) .nav__item-text {
    -webkit-transition-delay: 0.5s;
    transition-delay: 0.5s;
    }
    .nav__cb:checked ~ .nav__content .nav__item:nth-child(3) .nav__item-text {
    -webkit-transition-delay: 0.2s;
    transition-delay: 0.2s;
    }
    .nav__item:nth-child(4) .nav__item-text {
    -webkit-transition-delay: 0.4s;
    transition-delay: 0.4s;
    }
    .nav__cb:checked ~ .nav__content .nav__item:nth-child(4) .nav__item-text {
    -webkit-transition-delay: 0.3s;
    transition-delay: 0.3s;
    }
    .nav__item:nth-child(5) .nav__item-text {
    -webkit-transition-delay: 0.3s;
    transition-delay: 0.3s;
    }
    .nav__cb:checked ~ .nav__content .nav__item:nth-child(5) .nav__item-text {
    -webkit-transition-delay: 0.4s;
    transition-delay: 0.4s;
    }
    .nav__item:nth-child(6) .nav__item-text {
    -webkit-transition-delay: 0.2s;
    transition-delay: 0.2s;
    }
    .nav__cb:checked ~ .nav__content .nav__item:nth-child(6) .nav__item-text {
    -webkit-transition-delay: 0.5s;
    transition-delay: 0.5s;
    }
    .nav__item:nth-child(7) .nav__item-text {
    -webkit-transition-delay: 0.1s;
    transition-delay: 0.1s;
    }
    .nav__cb:checked ~ .nav__content .nav__item:nth-child(7) .nav__item-text {
    -webkit-transition-delay: 0.6s;
    transition-delay: 0.6s;
    }
    .nav__item:nth-child(8) .nav__item-text {
    -webkit-transition-delay: 0s;
    transition-delay: 0s;
    }
    .nav__cb:checked ~ .nav__content .nav__item:nth-child(8) .nav__item-text {
    -webkit-transition-delay: 0.7s;
    transition-delay: 0.7s;
    }
    .nav__btn {
    position: absolute;
    right: 0;
    top: 0;
    width: 60px;
    height: 60px;
    padding: 22px 17px;
    cursor: pointer;
    background: url(../../assets/image/tool_button.png) no-repeat;
    background-position-x: center;
    }
    .nav__btn:before, .nav__btn:after {
    content: "";
    display: block;
    width: 28px;
    height: 4px;
    border-radius: 2px;
    background: #bbb;
    -webkit-transform-origin: 50% 50%;
    transform-origin: 50% 50%;
    -webkit-transition: background-color 0.3s, -webkit-transform 1s cubic-bezier(0.48, 0.43, 0.29, 1.3);
    transition: background-color 0.3s, -webkit-transform 1s cubic-bezier(0.48, 0.43, 0.29, 1.3);
    transition: transform 1s cubic-bezier(0.48, 0.43, 0.29, 1.3), background-color 0.3s;
    transition: transform 1s cubic-bezier(0.48, 0.43, 0.29, 1.3), background-color 0.3s, -webkit-transform 1s cubic-bezier(0.48, 0.43, 0.29, 1.3);
    }
    .nav__btn:before {
    margin-bottom: 10px;
    }
    .nav__btn:hover:before, .nav__btn:hover:after {
    background: #fff;
    }
    .nav__cb:checked ~ .nav__btn:before {
    -webkit-transform: translateY(7px) rotate(-225deg);
    transform: translateY(7px) rotate(-225deg);
    }
    .nav__cb:checked ~ .nav__btn:after {
    -webkit-transform: translateY(-7px) rotate(225deg);
    transform: translateY(-7px) rotate(225deg);
    }

    没有人能一路单纯到底,但是要记住,别忘了最初的自己!
  • 相关阅读:
    七种常见的回归分析—转载
    Python模块之 __future__ 转载
    Java 快速排序
    在给定范围内产生指定个数不重复的随机数
    Java 冒泡排序
    jquery文本框效果
    jquery复选框
    struts2下的Ajax
    java线程系列---Runnable和Thread的区别
    System.getProperty("user.dir")
  • 原文地址:https://www.cnblogs.com/LindaBlog/p/10861105.html
Copyright © 2011-2022 走看看