動(dòng)畫效果

html文件

<!DOCTYPE html>
<html>
<head>
    <title>CSS3 動(dòng)畫</title>
    <meta charset="utf-8">
    <link rel="stylesheet" type="text/css" href="./animation.css">
</head>
<body>
    <button class="trans">過渡</button>
</body>
</html>

css文件

animation.css

.trans {
    width: 50em;
    height: 20em;
    background: #09f;
    border: 1px solid #05f;
    color: white;
    position: absolute;
    left: 0;
    transition-duration: 1s;
    animation-name: color_changes;/*動(dòng)畫名稱*/
    animation-duration: 3s;/*動(dòng)畫持續(xù)時(shí)間*/
    animation-iteration-count: infinite;/*動(dòng)畫重復(fù)次數(shù)*/
}
/*動(dòng)畫主體*/
@keyframes color_changes{
    0% {background-color: red;}
    20% {background-color: orange;}
    40% {background-color: yellow;}
    60% {background-color: green;}
    80% {background-color: blue;}
    100% {background-color: purple;}
}
/*當(dāng)鼠標(biāo)移上去時(shí)發(fā)生變化*/
.trans:hover {
    background: #05f;
    box-shadow: 1px 1px 2px #333;
    /*transition-duration: 1s;*/
    left: 20px;
    /*transform: rotateX(30deg);旋轉(zhuǎn)*/
    /*transform: translateY(100px);平移*/
    /*transform: skewY(30deg);傾斜*/
    /*transform: scale(5);縮放*/
    animation-name: color_changes;/*動(dòng)畫名稱*/
    animation-duration: 3s;/*動(dòng)畫持續(xù)時(shí)間*/
    animation-iteration-count: infinite;/*動(dòng)畫重復(fù)次數(shù)*/
}
body {
    perspective: 100px;/*定義 3D 元素距視圖的距離,以像素計(jì)*/
}
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容