矢印付き進捗プロセスcss

9391 ワード

html
<ul class="cssNav">
    <li v-for="(item,i) in list" :class="[num==i?'active':'']" @click="tab(i)">{{item}}li>
ul>

css
.cssNav {
        margin: 100px auto;
        background-color: #dedede;
        width:420px;
    }

    .cssNav li{
        padding:0 20px;
        line-height: 40px;
        background-color: #50abe4;
        display: inline-block;
        color:#fff;
        position: relative;
        margin-right: 4px;
    }
    .cssNav li:after{
        content:"";
        display: block;
        border-top:20px solid transparent;
        border-bottom:20px solid transparent;
        border-left:20px solid #50abe4;
        position: absolute;
        right:-20px;
        top:0;
        z-index: 10;
    }
    .cssNav li:before{
        content:"";
        display: block;
        border-top:20px solid transparent;
        border-bottom:20px solid transparent;
        border-left:20px solid #fff;
        position: absolute;
        left:0px;
        top:0;
    }

    .cssNav li:first-child{
        border-radius: 4px 0 0 4px;
        padding-left:25px;
    }
    .cssNav li:last-child,.cssNavEnd{
        border-radius: 0 4px 4px 0;
        padding-right: 25px;
    }
    .cssNav li:first-child:before{
        display: none;
    }
    .cssNav li:last-child:after,.cssNavEnd:after{
        display: none;
    }
    .cssNav li.active {  
        background-color: #ef72b6;  
    }  
    .cssNav li.active:after {  
        border-left-color: #ef72b6;  
    } 

js
//     vue.js 
 new Vue({
        el: '.cssNav',
        data: {
                num:0,
                list:['  ','    ','   ','   ']
            },
        methods: {
            tab:function(i){
                this.num = i;
            }
        }   
    })

説明:vueを使用しない場合.jsで書くには、スタイルをコピーするだけでいいです.