html+css實(shí)現(xiàn)環(huán)繞倒影加載特效

本文主要介紹了html+css實(shí)現(xiàn)環(huán)繞倒影加載特效,具體如下:
先看效果(完整代碼在底部):
實(shí)現(xiàn)(可一步一步邊看效果邊編寫):
※先初始化(直接復(fù)制):
*{ margin: 0; padding: 0; box-sizing: border-box; } body{ height: 100vh; display: flex; justify-content: center; align-items: center; background-color: rgb(7, 15, 26); }
flex布局,讓子元素居中對齊。
1.定義標(biāo)簽:
<div class="container"> <span>Loading...</span> <div class="circle"> <div class="ring"></div> </div> </div>
.container是最底層盒子。
span是文本。
.circle是底層圓形盒子。
.ring是那個藍(lán)色環(huán)。
2. .container的css樣式:
.container{ position: relative; height: 150px; width: 250px; -webkit-box-reflect:below 1px linear-gradient(transparent ,rgb(7, 15, 26)); }
-webkit-box-reflect:該屬性能實(shí)現(xiàn)倒影特效。詳細(xì)。
3. .circle的css樣式,動畫部分可暫時注釋掉:
.circle{ position: relative; margin: 0 auto; height: 150px; width: 150px; background-color: rgb(13, 10, 37); border-radius: 50%; animation: zhuan 2s linear infinite; } @keyframes zhuan{ 0%{ transform: rotate(0deg); } 100%{ transform: rotate(360deg); } }
margin: 0 auto;居中。
border-radius: 50%; 角弧度。
animation: zhuan 2s linear infinite; 設(shè)置動畫,讓其旋轉(zhuǎn)。
transform: rotate(…deg); 旋轉(zhuǎn)角度。
4. 定義一個雙偽類,為一個與背景色相同的小圓,覆蓋在.circle上:
.circle::after{ content: ''; position: absolute; top: 10px; left: 10px; right: 10px; bottom: 10px; background-color: rgb(7, 15, 26); border-radius: 50%; }
5.定義藍(lán)色環(huán)形效果,因?yàn)楸坏?步的小圓覆蓋了,所以直接定義一個漸變的藍(lán)色圓形即可得到藍(lán)色環(huán)形:
.ring{ position: absolute; top: 0; left: 0; width: 75px; height: 150px; background-image: linear-gradient(180deg,rgb(22, 121, 252) ,transparent 80%); border-radius: 75px 0 0 75px; }
background-image: linear-gradient(180deg,rgb(22, 121, 252) ,transparent 80%); 漸變顏色,先藍(lán)色,過渡到透明色。
6.定義環(huán)形上發(fā)光的小圓球:
.ring::after{ content: ''; position: absolute; right: -5px; top: -2.5px; width: 15px; height: 15px; background-color: rgb(40, 124, 202); box-shadow: 0 0 5px rgb(40, 151, 202), 0 0 10px rgb(40, 124, 202), 0 0 20px rgb(40, 124, 202), 0 0 30px rgb(40, 124, 202), 0 0 40px rgb(40, 124, 202), 0 0 50px rgb(40, 124, 202), 0 0 60px rgb(40, 124, 202), 0 0 60px rgb(40, 124, 202); border-radius: 50%; z-index: 1; }
box-shadow: 陰影。
z-index: 1; 顯示在最上層。
7. 定義文本loading:
.container>span{ position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); color: rgb(20, 129, 202); text-shadow: 0 0 10px rgb(20, 129, 202), 0 0 30px rgb(20, 129, 202), 0 0 60px rgb(20, 129, 202), 0 0 100px rgb(20, 129, 202); font-size: 18px; z-index: 1; }
left: 50%;
top: 50%;
transform: translate(-50%,-50%); 居中對齊。
text-shadow: 文字陰影。
完整代碼:
<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> *{ margin: 0; padding: 0; box-sizing: border-box; } body{ height: 100vh; display: flex; justify-content: center; align-items: center; background-color: rgb(7, 15, 26); } .container{ position: relative; height: 150px; width: 250px; -webkit-box-reflect:below 1px linear-gradient(transparent ,rgb(7, 15, 26)); } .container>span{ position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); color: rgb(20, 129, 202); text-shadow: 0 0 10px rgb(20, 129, 202), 0 0 30px rgb(20, 129, 202), 0 0 60px rgb(20, 129, 202), 0 0 100px rgb(20, 129, 202); font-size: 18px; z-index: 1; } .circle{ position: relative; margin: 0 auto; height: 150px; width: 150px; background-color: rgb(13, 10, 37); border-radius: 50%; animation: zhuan 2s linear infinite; } @keyframes zhuan{ 0%{ transform: rotate(0deg); } 100%{ transform: rotate(360deg); } } .circle::after{ content: ''; position: absolute; top: 10px; left: 10px; right: 10px; bottom: 10px; background-color: rgb(7, 15, 26); border-radius: 50%; } .ring{ position: absolute; top: 0; left: 0; width: 75px; height: 150px; background-image: linear-gradient(180deg,rgb(22, 121, 252) ,transparent 80%); border-radius: 75px 0 0 75px; } .ring::after{ content: ''; position: absolute; right: -5px; top: -2.5px; width: 15px; height: 15px; background-color: rgb(40, 124, 202); box-shadow: 0 0 5px rgb(40, 151, 202), 0 0 10px rgb(40, 124, 202), 0 0 20px rgb(40, 124, 202), 0 0 30px rgb(40, 124, 202), 0 0 40px rgb(40, 124, 202), 0 0 50px rgb(40, 124, 202), 0 0 60px rgb(40, 124, 202), 0 0 60px rgb(40, 124, 202); border-radius: 50%; z-index: 1; } </style> </head> <body> <div class="container"> <span>Loading...</span> <div class="circle"> <div class="ring"></div> </div> </div> </body> </html>
總結(jié):
到此這篇關(guān)于html+css實(shí)現(xiàn)環(huán)繞倒影加載特效的文章就介紹到這了,更多相關(guān)html+css環(huán)繞倒影加載內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持腳本之家!
相關(guān)文章
巧用 CSS3的webkit-box-reflect 倒影實(shí)現(xiàn)各類動效
這篇文章主要介紹了巧用 CSS3的webkit-box-reflect 倒影實(shí)現(xiàn)各類動效,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2021-03-05- 這篇文章主要通過一張圖給大家介紹了關(guān)于CSS3實(shí)現(xiàn)倒影的相關(guān)資料,文中給出來詳細(xì)的示例代碼供大家參考學(xué)習(xí),對大家學(xué)習(xí)或者使用css3具有一定的參考學(xué)習(xí)價值,需要的朋友們2017-09-26
CSS3 Notes: -webkit-box-reflect實(shí)現(xiàn)倒影的實(shí)例
這篇文章主要介紹了CSS3 Notes: -webkit-box-reflect實(shí)現(xiàn)倒影的實(shí)例,具有一定的參考價值,有需要的可以了解一下。2016-12-08- 以前要實(shí)現(xiàn)這種效果,我們只能乖乖的找設(shè)計去制作,然后在頁面上插入一張圖片,但是隨著CSS3的出現(xiàn),我們可以純代碼實(shí)現(xiàn),如何實(shí)現(xiàn)呢?就是通過CSS3的box-reflect屬性。下2016-11-15
- 下面小編就為大家?guī)硪黄?分鐘讓你掌握css3陰影、倒影、漸變小技巧(小編推薦)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-08-15
用CSS3的box-reflect設(shè)置文字倒影效果的方法講解
這篇文章主要介紹了用CSS3的box-reflect設(shè)置文字倒影效果的方法講解,文中舉了包括遮罩效果在內(nèi)的一些基礎(chǔ)的例子,需要的朋友可以參考下2016-03-07CSS3制作文字半透明倒影效果的兩種實(shí)現(xiàn)方式
CSS3制作文字半透明倒影效果,可以使用box-reflect以及transform屬性的scaleY方式,下面是具體的實(shí)現(xiàn)代碼,需要的朋友可以參考下2014-08-08- 無需flash,完全用css就可以做出超炫的圖片倒影效果,大伙不要不信;網(wǎng)上流傳很多種版本,經(jīng)過本人的一番研究,做成能夠兼容firefox、chrome、IE等各主流瀏覽器的版本,跟大2012-12-27