美文网首页
css镜像垂直动态导航栏

css镜像垂直动态导航栏

作者: 焦迈奇 | 来源:发表于2018-08-04 21:03 被阅读0次
<div class="container">
        <div class="box"><li class="text">first</li ></div>
        <div class="box"><li class="text">second</li></div>
        <div class="box"><li class="text">third</li></div>
        <div class="box"><li class="text">forth</li></div>
        <div class="box"><li class="text">fifth</li></div>
        <div class="box"><li class="text">sixth</li></div>
</div>
<script>
    //For Demo only
    var box = document.getElementsByClassName('box');
    console.log(box);
    for(var i = 0; i < box.length; i++)
        addClass(box,i);


    function addClass(box,id){
        setTimeout(function(){
            if(id > 0) {
                console.log(box[id-1].classList);
                box[id-1].classList.remove('hover');
            }
            box[id].classList.add('hover');
        }, id*750);
    }
</script>
html,body{
    width: 100%;
    height: 100%;
    margin:0;
    padding:0;
    background:lightgray;
}
.container{
    position:absolute;
    width:30%;
    height:50%;
    left:50%;
    top:50%;
    transform:translate(-50%,-50%);
    background:black;
    color:white;
}
.box{
    position:relative;
    width:100%;
    height:16%;
    overflow:hidden;
}
.text{
    display:inline-block;
    width:100%;
    height:51.75px;
    line-height:51.75px;
    text-align:center;
    vertical-align:middle;
    list-style-type:none;
    text-shadow:0 -40px 0 whitesmoke;
    transition:all 1s;
    transition-delay: 0.5s;
    transform:translateY(100%) ;
}
.box:after{
    position:absolute;
    content:"";
    left:-100%;
    width:80%;
    bottom:50%;
    border-bottom:2px solid floralwhite ;
    transition:all 0.5s;
    transition-delay: 1s;
}
.box:hover .text,
.box.hover .text{
    transform:translateY(0%) scale(1.1);
    font-weight:100;
}
.box:hover:after,
.box.hover:after{
    left:200%;
}

碰到了一个问题定义了类在元素上,而且设定来元素的动态效果,那么动态效果是否一直在保持?

结果不是,证明了在内部定义了动态效果,但元素并不会一直运动,而是只运动一次。

js脚本中,为元素添加类,classList.add();移除classList.remove();

相关文章

  • css镜像垂直动态导航栏

    碰到了一个问题定义了类在元素上,而且设定来元素的动态效果,那么动态效果是否一直在保持? 结果不是,证明了在内部定义...

  • Android隐藏状态栏、导航栏

    Android隐藏状态栏、导航栏 Android 动态隐藏显示导航栏,状态栏 一、导航栏: 相关: 二、状态栏: ...

  • 2020-06-06

    点击导航栏,导航栏和下面的副栏变色变内容 css部分 html部分 js部分

  • 2018-07-28

    自适应导航栏 HTML css

  • CSS常用操作

    一、尺寸操作 常用尺寸属性: 二、导航栏 导航栏可以分成两种,一种是垂直导航栏,一种是水平导航栏,但无论是什么结构...

  • 2019-04-06

    CSS导航栏 代码如下: 预览链接

  • css-进阶-css开发技巧-Component Skill:组

    下划线跟随导航栏 要点:下划线跟随鼠标移动的导航栏 场景:动态导航栏 兼容:+[https://caniuse.c...

  • 阻止页面元素被选中

    【问题】侧导航栏点击过快,会导致父导航栏及子导航栏均被选中。 【解决】 css在父元素中添加user-select...

  • bootstrap绝对定位写法

    以侧边导航栏为例 html代码 css代码

  • WEUI问题记录

    导航栏 tabbar停留在顶部 weui.css

网友评论

      本文标题:css镜像垂直动态导航栏

      本文链接:https://www.haomeiwen.com/subject/lhtvvftx.html