码迷,mamicode.com
首页 > 其他好文 > 详细

37.1拓展之按钮特效

时间:2019-02-21 00:34:24      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:for   frame   center   targe   完成   justify   splay   display   pre   

在线地址:https://scrimba.com/c/cWqNNnC2

HTML code:

<nav>
   <ul>
      <li>one</li>
      <li>two</li>
      <li>three</li>
   </ul>
</nav>

CSS code:

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: black
}
nav ul li{
    color: white;
    list-style: none;
    font-size: 24px;
    text-transform: uppercase;
    margin-top: 1em;
    padding: 1em 3em;
    border: 1px solid white;
    border-radius: 0.2em;
}
nav ul li:nth-of-type(1):hover{
    color: blue;
    border-color: blue;
    box-shadow: 0 0 0 3px blue;
}
nav ul li:nth-of-type(2):hover{
    color: blue;
    /* animation-fill-mode : none | forwards | backwards | both;
       forwards 当动画完成后,保持最后一个属性值.
    */
    animation: border-change 1s linear 0s forwards;
}
@keyframes border-change{
    0%{
        border-top-color: white;
    }
    25%{
        border-top-color: blue;
    }
    50%{
        border-top-color: blue;
        border-right-color: blue;
    }
    75%{
        border-top-color: blue;
        border-right-color: blue;
        border-bottom-color: blue;
    }
    100%{
        border-color: blue;
    }
}
nav ul li:nth-of-type(3){
    color: white;
    transition: 
            border-top-color linear 0.2s 0s,
            border-right-color linear 0.2s 0.2s,
            border-bottom-color linear 0.2s 0.4s,
            border-left-color linear 0.2s 0.6s;  
}
nav ul li:nth-of-type(3):hover{
    color: blue;
    border-top-color: blue;
    border-right-color: blue;
    border-bottom-color: blue;
    border-left-color: blue;
    /* 动画名称 进行时间 速度快慢 开始时间 */
    animation: pulse 1s linear 0.8s;
}
@keyframes pulse {
    from {
        /* rgb(30, 144, 255) = dodgerblue */
        box-shadow: 0 0 rgba(30, 144, 255, 0.5);
    }
    to {
        box-shadow: 0 0 0 1em rgba(30, 144, 255, 0);
    }
}

 

37.1拓展之按钮特效

标签:for   frame   center   targe   完成   justify   splay   display   pre   

原文地址:https://www.cnblogs.com/FlyingLiao/p/10409782.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!