先看效果╰(●?●)╮(完整代碼在底部):

這個是比較常見的一個簡約效果,拿下~
實作(可一步一步實作):
0.基本css樣式(復制即可)* :
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
body{
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background-color: rgb(4, 6, 17);
}
1.先定義標簽(詳解):
<div class="container">
<span style="--i:1;"></span>
<span style="--i:2;"></span>
<span style="--i:3;"></span>
<span style="--i:4;"></span>
<span style="--i:5;"></span>
<span style="--i:6;"></span>
<span style="--i:7;"></span>
<span style="--i:8;"></span>
<span style="--i:9;"></span>
<span style="--i:10;"></span>
</div>
.container就是底層盒子,span就是每個圈,
"- -i:1;"是css的var函式的運用,點這看用法~
2.底層盒子基本樣式:
.container{
position: relative;
width: 20px;
height: 20px;
transform-style: preserve-3d;
transform: perspective(500px) rotateX(50deg) translateZ(50px);
}
position:relative 相對定位,
transform-style:preserve-3d 子元素獲得3D位置,
perspective:元素距離視圖的距離,以像素計,
rotateX(50deg) 繞X軸旋轉50度,
translateZ(50px); 往Z軸偏移50px,
2.每個圓圈的css樣式,設定影片:
.container span{
position: absolute;
top: calc(-9px * var(--i));
left: calc(-9px * var(--i));
bottom: calc(-9px * var(--i));
right: calc(-9px * var(--i));
border: 5px solid rgba(0, 162, 255,0.8);
box-shadow: 0 6px 0 rgb(0, 162, 255),
inset 0 6px 0 rgba(0, 162, 255,.9);
/* background-color: rgba(0, 162, 255,0); */
border-radius: 50%;
animation: move 1.5s ease-in-out infinite alternate;
animation-delay: calc(var(--i) * 0.1s);
}
@keyframes move{
0%,100%{
transform: translateZ(0px);
}
50%{
transform: translateZ(-100px);
}
}
position: absolute; 絕對定位,
calc() 函式用于動態計算長度值,
top: calc(-9px * var(- -i));
left: calc(-9px * var(- -i));
bottom: calc(-9px * var(- -i));
right: calc(-9px * var(- -i)); 通過calc()計算每個圈的大小,
border: 5px solid rgba(0, 162, 255,0.8); 藍色邊框,
box-shadow: 0 6px 0 rgb(0, 162, 255),
inset 0 6px 0 rgba(0, 162, 255,.9); 陰影,一個外陰影,一個內陰影,目的是為了讓圓圈有點立體效果,
border-radius: 50%; 角弧度,
animation: move 1.5s ease-in-out infinite alternate; 定義影片,
animation-delay: calc(var(–i) * 0.1s); 通過calc()計算每個圈延遲多久后執行影片,
transform: translateZ(0px); Z軸方向的偏移,
完整代碼?(^?^●)ノ:
<!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(4, 6, 17);
}
.container{
position: relative;
width: 20px;
height: 20px;
transform-style: preserve-3d;
transform: perspective(500px) rotateX(50deg) translateZ(50px);
}
.container span{
position: absolute;
top: calc(-9px * var(--i));
left: calc(-9px * var(--i));
bottom: calc(-9px * var(--i));
right: calc(-9px * var(--i));
border: 5px solid rgba(0, 162, 255,0.8);
box-shadow: 0 6px 0 rgb(0, 162, 255),
inset 0 6px 0 rgba(0, 162, 255,.9);
/* background-color: rgba(0, 162, 255,0); */
border-radius: 50%;
animation: move 1.5s ease-in-out infinite alternate;
animation-delay: calc(var(--i) * 0.1s);
}
@keyframes move{
0%,100%{
transform: translateZ(0px);
}
50%{
transform: translateZ(-100px);
}
}
</style>
</head>
<body>
<div class="container">
<span style="--i:1;"></span>
<span style="--i:2;"></span>
<span style="--i:3;"></span>
<span style="--i:4;"></span>
<span style="--i:5;"></span>
<span style="--i:6;"></span>
<span style="--i:7;"></span>
<span style="--i:8;"></span>
<span style="--i:9;"></span>
<span style="--i:10;"></span>
</div>
</body>
</html>
總結:
MEGALOBOX 第二季上映了,三年呀,,,仿佛就在昨天,

其它文章:
環繞倒影加載特效 html+css
氣泡浮動背景特效 html+css
簡約時鐘特效 html+css+js
賽博朋克風格按鈕 html+css
仿網易云官網輪播圖 html+css+js
水波加載影片 html+css
導航欄滾動漸變效果 html+css+js
書本翻頁 html+css
3D立體相冊 html+css
霓虹燈繪畫板效果 html+css+js
記一些css屬性總結(一)
Sass總結筆記
…等
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/276202.html
標籤:其他
