37.1拓展之按钮特效
Posted flyingliao
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了37.1拓展之按钮特效相关的知识,希望对你有一定的参考价值。
在线地址: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拓展之按钮特效的主要内容,如果未能解决你的问题,请参考以下文章