css+div实现三维立体笑脸表情checkbox开关切换效果代码

代码语言:html

所属分类:布局界面

代码描述:css+div实现三维立体笑脸表情checkbox开关切换效果代码

代码标签: css div 三维 立体 笑脸 表情 checkbox 开关 切换

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

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

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

  <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
  
  
  
<style>
* {
  border: 0;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --hue: 223;
  --bg: hsl(var(--hue),10%,90%);
  --fg: hsl(var(--hue),10%,10%);
  --trans-dur: 0.5s;
  --trans-timing1: cubic-bezier(0.65,0,0.35,1);
  --trans-timing2: cubic-bezier(0.65,0,0.35,1.5);
  font-size: calc(56px + (120 - 56) * (100vw - 280px) / (3840 - 280));
}

body,
input {
  color: var(--fg);
  font: 1em/1.5 sans-serif;
  transition: background-color var(--trans-dur) var(--trans-timing1), color var(--trans-dur) var(--trans-timing1);
}

body {
  background-color: var(--bg);
  display: flex;
  height: 100vh;
}

.switch {
  display: flex;
  margin: auto;
}
.switch__emoji {
  box-shadow: 0.25em 0.25em 0.125em rgba(0, 0, 0, 0.3);
  overflow: hidden;
  pointer-events: none;
  top: 0.25em;
  left: 0.25em;
  width: 1em;
  height: 1em;
}
[dir=rtl] .switch__emoji {
  right: 0.25em;
  left: auto;
}
.switch__emoji, .switch__emoji:before, .switch__emoji:after, .switch__emoji-eye, .switch__emoji-mouth, .switch__emoji-face {
  display: block;
  position: absolute;
}
.switch__emoji, .switch__emoji:before, .switch__emoji:after, .switch__emoji-eye, .switch__emoji-mouth {
  border-radius: 50%;
}
.switch__emoji:before, .switch__emoji:after {
  content: "";
  width: 100%;
  height: 100%;
  transform: translateZ(0);
}
.switch__emoji:before {
  background-color: #f2c40d;
  box-shadow: -0.25em -0.25em 0.25em #c29d0a inset, 0.1875em 0.1875em 0.25em #f9e286 inset;
}
.switch__emoji:after {
  box-shadow: 0 0 0.125em 0.0625em rgba(245, 208, 61, 0.5) inset;
}
.switch__emoji, .switch__emoji-face {
  transform-style: preserve-3d;
  transition: transform var(--trans-dur) var(--trans-timing2);
}
.switch__emoji-eye, .switch__emoji-mouth {
  backface-visibility: hidden;
}
.switch__emoji-eye {
  border: 0.0625em solid hsl(var(--hue), 10%, 10%);
  border-right-color: transparent;
  border-bottom-color: transparent;
  border-radius: 50%;
  top: 50%;
  left: 50%;
  width: 0.25em;
  height: 0.25em;
  transform: translate(-50%, -50%) rotateY(-22.5deg) translateZ(0.5em) rotateZ(45deg);
}
.switch__emoji-eye + .switch__emoji-eye {
  transform: translate(-50%, -50%) rotateY(22.5deg) translateZ(0.5em) rotateZ(45deg);
}
.switch__emoji-mouth {
  background-image: radial-gradient(100% 100% at 50% 100%, #f2180d 20%, #f5463d 33%, rgba(245, 70, 61, 0) 35%), radial-gradient(100% 100% at 75% 113%, black 26%, rgba(0, 0, 0, 0) 35%), linear-gradient(rgba(0, 0, 0, 0) 50%, black 50% 55%, hsl(var(--hue), 10%, 10%) 65%);
  top: 50%;
  left: 50%;
  width: 0.5em;
  height: 0.5em;
  transform: translate(-50%, -50%) rotateX(-15deg) translateZ(0.5em);
}
.switch__emoji-face {
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform: rotateY(0);
}
.switch__emoji-face + .switch__emoji-face {
  transform: rotateY(-180deg);
}
.switch__emoji-face--sad .switch__emoji-eye {
  background-color: hsl(var(--hue), 10%, 10%);
  border: 0;
  width: 0.1875em;
  height: 0.1875em;
}
.switch__emoji-face--sa.........完整代码请登录后点击上方下载按钮下载查看

网友评论0