svg+css实现逼真物理开关按键点击带音效效果代码

代码语言:html

所属分类:布局界面

代码描述:svg+css实现逼真物理开关按键点击带音效效果代码

代码标签: svg css 逼真 物理 开关 按键 点击 音效

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

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

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

  
  
  
<style>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  background-color: #fff;
  transition-property: background-color;
  transition-duration: 0.2s;
}

.switch-container {
  position: relative;
  border-radius: 3.125em;
  box-shadow: 0 0.125em 0.25em rgba(0, 0, 0, 0.2);
  overflow: hidden;
  cursor: pointer;
}

.switch-input {
  appearance: none;
  position: absolute;
  z-index: 1;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.switch-button {
  display: inline-flex;
  padding: 0 0.375em;
  border-radius: inherit;
  border: 0.0625em solid #6b717b;
  background-color: #aaafbb;
  box-shadow: inset 0 0 0.5em rgba(0, 0, 0, 0.4);
  transition-property: border-color, background-color;
  transition-duration: 0.2s;
}
.switch-input:checked + .switch-button {
  border-color: #43316f;
  background-color: #7550d9;
}

.switch-button-inside {
  display: inline-flex;
  column-gap: 1em;
  position: relative;
  border-radius: inherit;
  padding: 0.75em;
  transform: translateX(-0.375em);
  background-image: linear-gradient(90deg, #c5c9d3 48%, #d5d7dd 52%);
  box-shadow: inset 0.0625em 0 0.0625em rgba(255, 255, 255, 0.4), inset -0.0625em 0 0.0625em rgba(255, 255, 255, 0.4);
  transition-property: transform;
  transition-duration: 0.2s;
}
.switch-button-inside::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  border-radius: inherit;
  background-image: linear-gradient(90deg, #926afe 48%, #885bff 52%);
  box-shadow: inset 0.0625em 0 0.0625em rgba(255, 255, 255, 0.2), inset -0.0625em 0 0.0625em rgba(255, 255, 255, 0.2);
  opacity: 0;
  transition-property: opacity;
  transition-duration: 0.2s;
}
.switch-input:checked + .swi.........完整代码请登录后点击上方下载按钮下载查看

网友评论0