js+css实现点击产生电流给插座充电动画效果代码
代码语言:html
所属分类:动画
代码描述:js+css实现点击产生电流给插座充电动画效果代码,点击按钮产生电流。
代码标签: js css 点击 产生 电流 插座 充电 动画
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<style>
@font-face {
font-family: 'Departure Mono';
src: url('//repo.bfw.wiki/bfwrepo/font/DepartureMono-Regular.woff2') format('woff2');
}
*{ box-sizing: border-box; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; scroll-behavior: smooth;}
html, body { height: 100%; overflow: hidden;}
body {
font-family: Departure Mono;
background: #1e1e1e;
background: linear-gradient(28deg, #111, #272727);
color: #fff;
position: relative;
height: 100%;
}
.face {
--xv: 0; --yv: 0;
background: #141414;
background: #fff1;
background-image: radial-gradient(transparent 1px, #111 0);
background-size: 3px 3px;
font-weight: 1000;
position: absolute; margin: auto;
left: 0; right: 0;top: 0;bottom: 3em;
width: 3em; height: 3em;
border-radius: 10px;
border: 1px solid #fff2;
display: flex;
justify-content: center; align-items: center;
padding-top: 1em;
overflow: hidden;
user-select: none;
box-shadow:
0px 0px 0px 2px #0005,
0px 0px 0px 1px #fff3,
-2px 2px 2px -1px #000,
0px 0px 12px 0px #fff0,
inset -2px 2px 3px -2px #fffa;
cursor: pointer;
transition: all 0.4s ease-out;
backdrop-filter: blur(10px);
perspective: 1000px;
}
.face #eyel { translate: 0 -1em; }
.face #eyer { translate: 0 -1em; }
body:has( .pwr-btn:not(.empty) ) .face {
box-shadow:
0px 0px 0px 2px #0005,
0px 0px 0px 1px #fff3,
-2px 2px 2px -1px #000,
0px 0px 12px 0px #fff2,
inset -2px 2px 3px -2px #fffa;
}
.face > * {
text-shadow:
-3px 3px 3px #000c,
0 1px 12px #fffa,
0 0 5px #fff;
}
body:has( .pwr-btn:not(.empty) ) .face:hover > * {
transform: translateX(calc(var(--yv) * 0.2px)) translateY(calc(var(--xv) * -0.2px));
transition: all 0.4s ease-out;
}
body:has( .pwr-btn.empty ) .face > * {
opacity: 0.2;
}
.face::before {
content: '';
display: block;
width: 100%; height: 100%;
position: absolute; top: 0; left: 0;
box-shadow:
inset -2px 2px 2px 0px #fff5,
inset 2px -2px 2px 1px #1118;
scale: 1.1;
border-radius: 12px;
transform: translateX(calc(var(--yv) * 0.2px)) translateY(calc(var(--xv) * -0.2px));
transition: all 0.4s ease-out;
}
.face::after {
content: '';
display: block;
width: 200%;
height: 0.6em;
background: #fff2;
position: absolute;
rotate: 24deg;
top: -50%;
transition: all 0.4s ease-in-out;
}
.face:hover {
scale: 2;
box-shadow:
-24px 33px 8px -10px #0005,
0px 0px 0px 1px #fff3,
-2px 2px 2px -1px #000,
0px 0px 12px 0px #fff0,
inset -2px 2px 3px -2px #fffc !important;
}
.face:hover::after {
top: 150%;
rotate: 42deg;
}
.pwr-btn {
position: absolute;
left: 0; right: 0; top: 2em;bottom: 0; margin: auto;
translate: 0 min(10em, 30vh);
background: #141414;
background: #5478ad85;
background-image: radial-gradient(transparent 1px, #111 0);
background-size: 3px 3px;
width: fit-content; height: fit-content;
padding: 0.4em 1.6em;
border: 1px solid #fff4;
border-radius: 6px;
cursor: pointer;
box-shadow:
0px 0px 0px 2px #0005,
0px 0px 0px 1px #fff3,
0px 0px 0px 1px #fff3,
-2px 2px 2px -1px #000,
0px 0px 12px 0px #fff2,
inset -2px 2px 3px -2px #fffa;
text-shadow:
0 1px 12px #fffa,
0 0 5px #fff;
user-select: none;
transition: all 0.4s ease-in-out;
}
.pwr-btn::before {
content: ''; display: block;
position: absolute;
left: 0; bottom: 0;
border-bottom-left-radius: 6px;
border-bottom-right-radius: 6px;
background: #fff;
mix-blend-mode: difference;
filter: blur(1px);
height: calc(var(--power, 0) * 1%); width: 100%;
transition: all 0.4s ease-in-out;
}
.pwr-btn.full::before {
border-radius: 6px;
}
.pwr-btn.full{
filter: brightness(1.2);
box-shadow:
0px 0px 0px 2px #0005,
0px 0px 6px 1px #fff3,
0px 0px 12px 1px #fff3,
-2px 2px 2px -1px #000,
0px 0px 12px 0px #fff2,
inset -2px 2px 3px -2px #fffa;
}
.pwr-btn.empty {
filter: brightness(0.5);
}
.power-line {
position: absolute;
left: 0; right: 0; top.........完整代码请登录后点击上方下载按钮下载查看
网友评论0