代碼
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CSS3 動(dòng)畫(huà)</title>
<style>
.img {
width: 150px;
}
@keyframes rotate {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
img:hover {
animation: rotate 0.5s linear infinite;
}
</style>
</head>
<body>
<img src="images/fengche.png" alt="">
</body>
</html>
上述代碼中:
第10行代碼定義animation屬性實(shí)現(xiàn)動(dòng)畫(huà)效果;
第10~17行代碼定義rotate動(dòng)畫(huà)讓圖片從0%到100%順時(shí)針旋轉(zhuǎn)360度;
第18~20行代碼通過(guò)animation動(dòng)畫(huà)實(shí)現(xiàn)當(dāng)鼠標(biāo)指針懸停在圖片上時(shí)讓圖片不停的旋轉(zhuǎn)。文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-785884.html
運(yùn)行效果
CSS3 動(dòng)畫(huà)文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-785884.html
CSS3可以創(chuàng)建動(dòng)畫(huà),它可以取代許多網(wǎng)頁(yè)動(dòng)畫(huà)圖像、Flash動(dòng)畫(huà)和JavaScript實(shí)現(xiàn)的效果。
animation屬性用于描述動(dòng)畫(huà)的CSS聲明,包括指定具體動(dòng)畫(huà)以及動(dòng)畫(huà)化時(shí)長(zhǎng)等行為。
到了這里,關(guān)于響應(yīng)式Web開(kāi)發(fā)項(xiàng)目教程(HTML5+CSS3+Bootstrap)第2版 例3-5 CSS3 動(dòng)畫(huà)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!