佳木斯湛栽影视文化发展公司

主頁 > 知識庫 > html+css實現(xiàn)充電水滴融合特效代碼

html+css實現(xiàn)充電水滴融合特效代碼

熱門標簽:檢查注冊表項 網(wǎng)站建設 硅谷的囚徒呼叫中心 使用U盤裝系統(tǒng) 智能手機 美圖手機 阿里云 百度競價點擊價格的計算公式

先看效果:

前言:

這個思路是我在b站看up主Steven做的,覺得很不錯,然后自己也弄了一個。(純css)

實現(xiàn):

定義標簽,有三個水滴盒子,一個圓圈盒子顯示數(shù)字,一個最底層盒子:

<div class="kuang">
      <div class="droplet"></div>
      <div class="droplet"></div>
      <div class="droplet"></div>
      <div class="quan"></div>
      <span>99%</span>
   </div>

給最底層盒子基本的樣式。flex布局,這樣3個水滴暫時會垂直居中排列。

.kuang{
            position: relative;
            height: 100vh;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            background-color: rgb(5,5,5);
            filter: contrast(30);
        }

filter: contrast(30);調(diào)整圖像的對比度。值是0%的話,圖像會全黑。值是100%,圖像不變。值可以超過100%,意味著會運用更低的對比。若沒有設置值,默認是1。

水滴的基本樣式。絕對定位,這樣3個盒子會重疊一起。

.droplet{
           position: absolute;
            width: 100px;
            height: 100px;
            border-radius: 50%;
            background-color: rgb(61, 233, 99);
            filter: blur(20px);
            animation: fall 3s linear infinite;
            opacity: 0;
        }

filter: blur(20px);給圖像設置模糊。

重點:我們給水滴盒子模糊度,這然三個水滴盒子會呈現(xiàn)一種模糊的狀態(tài)。繼而,我們給底層盒子設置圖像對比度,這樣模糊的圖片會重新繪制輪廓,而得到下面的效果:

給要顯示數(shù)字的圓圈基本樣式。記住也要設置模糊度。這樣在圖像對比度下才會有與下落的水滴有融合的效果。

.quan{
            position: absolute;
            width: 100px;
            height: 100px;
            border-radius: 50%;
            background-color: rgb(61, 233, 99);
            filter: blur(20px);
            animation: zhuan 3s  infinite;
        }

給水滴設置動畫,讓它們從上往下落下,期間大小發(fā)生變化,這些可以自己慢慢調(diào)試,設置成自己認為最好的效果。

 @keyframes fall{
            0%{
                opacity: 0;
                transform:  scale(0.8) translateY(-500%);               
            }
            50%{
                opacity: 1;
                transform: scale(0.5) translateY(-100%) ;
            }
            100%{
                   transform: scale(0.3) translateY(0px);
            }
        }

第2和和第3個水滴延遲時間后再播放動畫,這樣3個水滴才會分開下落,至于幾秒可以自己慢慢調(diào)試,設置成自己認為最好的效果。

.kuang div:nth-of-type(2){
            animation-delay: 1.5s;
        }
        .kuang div:nth-of-type(3){
            animation-delay: 2s;
        }

給顯示數(shù)字的圓圈動畫效果,讓它轉(zhuǎn)起來。期間可以讓它大小或角度發(fā)生或其它變化,具體數(shù)值可以自己慢慢調(diào)試,設置成自己認為最好的效果。

@keyframes zhuan{
            0%{
              transform: scale(1) rotate(0deg);
            }
            50%{
                transform: scale(1.1) rotate(180deg);
                height: 90px;
                border-top-left-radius: 45%;
                border-bottom-left-radius: 48%;

            }
            100%{
                transform:scale(1) rotate(360deg);
            }
        }

完整代碼:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>北極光之夜。</title>
    <style>
        *{
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        .kuang{
            position: relative;
            height: 100vh;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            background-color: rgb(5,5,5);
            filter: contrast(30);
        }
        .droplet{
           position: absolute;
            width: 100px;
            height: 100px;
            border-radius: 50%;
            background-color: rgb(61, 233, 99);
            filter: blur(20px);
            animation: fall 3s linear infinite;
            opacity: 0;
        }
        .kuang div:nth-of-type(2){
            animation-delay: 1.5s;
        }
        .kuang div:nth-of-type(3){
            animation-delay: 2s;
        }
        @keyframes fall{
            0%{
                opacity: 0;
                transform:  scale(0.8) translateY(-500%);               
            }
            50%{
                opacity: 1;
                transform: scale(0.5) translateY(-100%) ;
            }
            100%{
                   transform: scale(0.3) translateY(0px);
            }
        }
        .quan{
            position: absolute;
            width: 100px;
            height: 100px;
            border-radius: 50%;
            background-color: rgb(61, 233, 99);
            filter: blur(20px);
            animation: zhuan 3s  infinite;
        }
        @keyframes zhuan{
            0%{
              transform: scale(1) rotate(0deg);
            }
            50%{
                transform: scale(1.1) rotate(180deg);
                height: 90px;
                border-top-left-radius: 45%;
                border-bottom-left-radius: 48%;

            }
            100%{
                transform:scale(1) rotate(360deg);
            }
        }
      span{
          position: absolute;
          color: rgb(184, 182, 182);
          font-size: 26px;
          font-family: 'fangsong';
          font-weight: bold;
      }
    </style>
</head>
<body>
    <div class="kuang">
      <div class="droplet"></div>
      <div class="droplet"></div>
      <div class="droplet"></div>
      <div class="quan"></div>
      <span>99%</span>
   </div>
</body>
</html>

總結(jié):

到此這篇關于html+css實現(xiàn)充電水滴融合特效代碼的文章就介紹到這了,更多相關html 水滴融合內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持腳本之家!

標簽:黃山 湖北 懷化 煙臺 湘潭 山南 通遼 賀州

巨人網(wǎng)絡通訊聲明:本文標題《html+css實現(xiàn)充電水滴融合特效代碼》,本文關鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權問題,煩請?zhí)峁┫嚓P信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡,涉及言論、版權與本站無關。
  • 相關文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266
    柘荣县| 尚义县| 江西省| 磐安县| 上高县| 微博| 三门峡市| 瑞安市| 聂拉木县| 平潭县| 丹凤县| 长兴县| 元阳县| 神池县| 合肥市| 梓潼县| 山丹县| 平阳县| 永安市| 鄄城县| 金溪县| 延吉市| 满洲里市| 辽中县| 九龙城区| 泽普县| 清镇市| 南丰县| 彩票| 衡阳市| 横峰县| 台南市| 潼南县| 大洼县| 西平县| 广河县| 鸡东县| 虎林市| 兰西县| 灌南县| 深州市|