css布局实现可点击开关的小夜灯效果代码

代码语言:html

所属分类:布局界面

代码描述:css布局实现可点击开关的小夜灯效果代码

代码标签: 点击 开关 小夜灯 效果

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开


<!DOCTYPE html>
<html lang="en" >

<head>

  <meta charset="UTF-8">


  
<style>
html {
  box-sizing: border-box;
}

*,
*::after,
*::before {
  box-sizing: inherit;
}

html,
body {
  height: 100%;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  font-size: 14px;
  background-color: #efd4b6;
}

html {
  box-sizing: border-box;
}

*,
*::after,
*::before {
  box-sizing: inherit;
}

html,
body {
  height: 100%;
}

body {
  --bg-default: #484367;
  --line-default: #706897;
  --line-default-500: #4b456c;
  --additional-light: #d8b269;
  --bg-shadow: #443e65;
  --text-headline: #fff4e3;
  --text-subtitle: #f6ebd9;
  --glare: #ffdd96;
}

body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  overflow-x: hidden;
  font-size: 16px;
  background-color: var(--bg-default);
  margin-bottom: 40px;
}

a {
  text-decoration: none;
  color: inherit;
}

@keyframes fade-out {
  0% {
    opacity: 1;
    visibility: visible;
  }
  100% {
    opacity: 0;
    visibility: hidden;
  }
}
.lamp-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  cursor: pointer;
  user-select: none;
}
.lamp-container > .glare {
  pointer-events: none;
  height: 600px;
  width: 700px;
  position: absolute;
  left: 50%;
  top: 48%;
  transform: translate(-50%, -50%);
  background-color: var(--glare);
  z-index: 4;
  filter: blur(80px);
  border-radius: 50%;
  opacity: 0;
  visibility: hidden;
}
.lamp-container > .control {
  display: none;
}
.lamp-container > .base {
  position: relative;
  z-index: 1;
}
.lamp-container > .base > .light {
  display: none;
  position: absolute;
  left: 50%;
  top: 56%;
  transform: translateX(-50%);
  filter: blur(20px);
}
.lamp-container > .support {
  width: 72%;
  margin-top: -8px;
}
.lamp-container > .additionalLight {
  display: none;
  background-color: var(--additional-light);
  width: 270px;
  height: 280px;
  border-radius: 62% 61% 66% 58%/79% 96% 33% 29%;
  position: absolute;
  top: 24px;
  z-index: -2;
  filter: blur(24px);
  transform: scale(1.2);
}
.lamp-container > .shadow {
  width: 50%;
  height: 14px;
  border-radius: 58% 61% 63% 58%/76% 72% 52% 49%;
  background-color: var(--bg-shadow);
  filter: blur(8px);
  position: absolute;
  bottom: 8px;
  z-index: -1;
}
.lamp-container > .background::after {
  content: "";
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: -3;
  background: var(--bg-default);
}
.lamp-container > .headline {
  position: absolute;
  right: -112%;
  bottom: 88px;
  width: 240px;
  display: none;
}

.base-container {
  height: 278px;
  width: 248px;
  overflow: hidden;
  border-radius: 62% 61% 66% 58%/79% 96% 33% 29%;
  background-image: repeating-radial-gradient(ellipse at 9% -75%, var(--line-default), var(--line-default) 3px, rgba(255, 255, 255, 0) 4px, var(--line-default) 11px);
  background-size: 600% 208%;
  position: relative;
}
.base-container::before {
  content: "";
  height: 106%;
  width: 160px;
  border-left: 2px solid var(--line-default-500);
  position: absolute;
  left: 13%;
  top: -3%;
  border-radius: 79% 0% 66% 58%/100% 99% 5% 29%;
}
.base-container::after {
  content: "";
  height: 107%;
  width: 97px;
  border: 2px solid var(--line-default-500);
  position: absolute;
  left: 43%;
  top: -2%;
  border-radius: 28% 100% 87% 47%/83% 87% 37% 16%;
}
.base-container > .depth {
  height: 148px;
  width: 117px;
  margin-top: 21px;
  background-color: #6e6993;
  border-radius: 62% 37% 46% 45%/52% 41% 10% 33%;
  filter: blur(24px);
  opacity: 0.92;
  position: relative;
  margin-left: 47%;
  z-index: 2;
}

.hook-element {
  width: 14px;
  height: 38px;
  border-top: 2px solid #221c1d;
  border-left: 2px solid #221c1d;
  border-right: 2px solid #221c1d;
  border-radius: 50% 50% 0% 0%/36% 36% 10% 10%;
  position: relative;
}
.hook-element::after {
  position: absolute;
  z-index: -1;
  bottom: -4px;
  height: 8px;
  width: 300%;
  left: 50%;
  border-radius: 50%;
  transform: translateX(-50%);
  background-color: red;
}

.leg-support {
  border-top: 2px solid #221c1d;
  border-left.........完整代码请登录后点击上方下载按钮下载查看

网友评论0