技術(shù)頻道導(dǎo)航
HTML/CSS
.NET技術(shù)
IIS技術(shù)
PHP技術(shù)
Js/JQuery
Photoshop
Fireworks
服務(wù)器技術(shù)
操作系統(tǒng)
網(wǎng)站運(yùn)營(yíng)

贊助商

分類目錄

贊助商

最新文章

搜索

CSS loading加載動(dòng)畫(huà)(旋轉(zhuǎn)的圓環(huán))

作者:admin    時(shí)間:2022-1-19 20:52:17    瀏覽:

CSS loading 加載動(dòng)畫(huà)用于程序加載過(guò)程中的顯示,它的作用是告訴用戶程序還在進(jìn)行中,不要關(guān)閉窗口。有些人用GIF圖片來(lái)設(shè)計(jì)loading加載畫(huà)面,本文介紹用純CSS來(lái)實(shí)現(xiàn)一個(gè)loading加載動(dòng)畫(huà)。

demodownload

HTML

HTML代碼十分簡(jiǎn)單,只有一個(gè)div,div里也只有一個(gè)類屬性loader。

<div class="loader"></div>

CSS

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

@-webkit-keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loader {
  border-width: 0.25rem;
  border-style: solid;
  border-color: gainsboro gainsboro dodgerblue gainsboro;
  border-radius: 50%;
  display: block;
  width: 4rem;
  height: 4rem;
  -webkit-animation: rotate 1.5s linear infinite;
          animation: rotate 1.5s linear infinite;
}

.loader 定義圓邊的樣式。

animation: rotate 1.5s linear infinite; 這里rotate意思為旋轉(zhuǎn),1.5s為每1.5秒完成一次運(yùn)動(dòng),infinite為循環(huán)進(jìn)行,linear為動(dòng)畫(huà)從頭到尾的速度是相同的。

@keyframes rotate 定義圓環(huán)的旋轉(zhuǎn)方向和角度。

您可能對(duì)以下文章也感興趣

x
  • 站長(zhǎng)推薦
/* 左側(cè)顯示文章內(nèi)容目錄 */