- 資訊首頁(yè) > 開(kāi)發(fā)技術(shù) >
- 如何使用CSS3實(shí)現動(dòng)畫(huà)效果
這篇文章主要為大家展示了“如何使用CSS3實(shí)現動(dòng)畫(huà)效果”,內容簡(jiǎn)而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學(xué)習一下“如何使用CSS3實(shí)現動(dòng)畫(huà)效果”這篇文章吧。
Internet Explorer 10、Firefox 以及 Opera 支持 animation 屬性。
Safari 和 Chrome 支持替代的 -webkit-animation 屬性。
注釋?zhuān)篒nternet Explorer 9 以及更早的版本不支持 animation 屬性。
定義和用法
animation屬性是一個(gè)簡(jiǎn)寫(xiě)屬性,用于設置六個(gè)動(dòng)畫(huà)屬性:
animation-name
animation-duration
animation-timing-function animation-delay
animation-iteration-count animation-direction
語(yǔ)法
animation: name duration timing-function delay iteration-count direction;
關(guān)于keyframe的定義
Firefox支持替代的@-moz-keyframes規則;
Opera支持替代的@-o-keyframes規則;
Safari和Chrome支持替代的@-webkit-keyframes規則;
取值支持 0-100% 和from,to。
@keyframes move { 0% { top: 0px; left: 0px; } 25% { top: 200px; left: 200px; } 50% { top: 100px; left: 100px; } 75% { top: 200px; left: 200px; } 100% { top: 0px; left: 0px; } } @keyframes move { from { top: 0px; left: 0px; } to { top: 0px; left: 100px; } }
demo 寫(xiě)了一個(gè)例子,地球繞太陽(yáng)轉
以下是代碼
<!-- html 部分 --> <div style="width:700px; "> <div class="t"> <div class="t1"></div> </div> </div>
/* css 部分 */ @keyframes t { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } @-webkit-keyframes t { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } .t { height: 500px; width: 500px; position: relative; border-radius: 50%; transform: scale(.8); border: 1px solid #dedede; &::before { content: ""; width: 50px; height: 50px; background: radial-gradient(72px, #f00, #ff0, #080); border-radius: 50%; position: absolute; left: 50%; top: 50%; margin-top: -25px; margin-left: -25px; box-shadow: 0 0 37px #fcff4a; } .t1 { height: 20px; border-radius: 50%; width: 20px; margin-top: -10px; top: 50%; left: -10px; background: radial-gradient(26px, #0082ff, #184608, #003ade); position: absolute; animation: t 3s infinite linear; transform-origin: 260px center; } } </style>
免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng )、來(lái)自互聯(lián)網(wǎng)轉載和分享為主,文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權請聯(lián)系QQ:712375056 進(jìn)行舉報,并提供相關(guān)證據,一經(jīng)查實(shí),將立刻刪除涉嫌侵權內容。
Copyright ? 2009-2021 56dr.com. All Rights Reserved. 特網(wǎng)科技 特網(wǎng)云 版權所有 珠海市特網(wǎng)科技有限公司 粵ICP備16109289號
域名注冊服務(wù)機構:阿里云計算有限公司(萬(wàn)網(wǎng)) 域名服務(wù)機構:煙臺帝思普網(wǎng)絡(luò )科技有限公司(DNSPod) CDN服務(wù):阿里云計算有限公司 中國互聯(lián)網(wǎng)舉報中心 增值電信業(yè)務(wù)經(jīng)營(yíng)許可證B2
建議您使用Chrome、Firefox、Edge、IE10及以上版本和360等主流瀏覽器瀏覽本網(wǎng)站