svg+css实现台灯按钮点击开灯关灯效果代码

代码语言:html

所属分类:其他

代码描述:svg+css实现台灯按钮点击开灯关灯效果代码

代码标签: svg css 台灯 按钮 点击 开灯 关灯

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

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

<head>
  <meta charset="UTF-8">
  

  
  
  
  
<style>
body {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #26282D;
}

* {
  box-sizing: border-box;
}

#lib {
  position: fixed;
  visibility: hidden;
}

.lib {
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  transform: scale(2);
}
.lib svg {
  display: block;
}
.lib svg path {
  transition: all 0.3s ease;
}
.lib svg path.onoff {
  opacity: 0.8;
}
.lib svg path.shine {
  opacity: 0;
}
.lib svg path.lamp {
  opacity: 0;
}
.lib:hover {
  background: rgba(0, 0, 0, 0.12);
}

#lib:checked + .lib svg path:not(.shine, .lamp) {
  stroke: #C1B971;
}
#lib:checked + .lib svg path.onoff {
  animation: updown 0.4s linear forwards;
}
#lib:checked + .lib svg path.shine {
  opacity: 1;
}
#lib:checked + .lib svg path.lamp {
  opacity: 1;
}

@keyframes updown {
  0% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(1px);
  }
  100% {
    transform: translateY(0);
  }
}
</style>

</head>

<body >
  <input type="checkbox" id="lib">
<label for="lib" class="lib">
  <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M8 20H12M16 20H12M12 20V11" stroke="#ACA6A9" stroke-width="2" s.........完整代码请登录后点击上方下载按钮下载查看

网友评论0