div+css实现拖动控制头发长度效果代码

代码语言:html

所属分类:拖放

代码描述:div+css实现拖动控制头发长度效果代码

代码标签: div css 拖动 控制 头发 长度

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

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

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

  
<style>
@charset "UTF-8";
body {
  display: grid;
  place-content: center;
  height: 100vh;
  --br: #7e671c;
  --dbr: #1d1f20;
  --p: #f5eace;
  --t: rgba(255, 255, 255, 0.001);
  background: radial-gradient(circle at center, #f7faf9 100px, #c1d7cc);
}

#wrap {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  height: 400px;
  width: 200px;
  transform: translate(-25px, 25px);
}
#wrap #face {
  width: 140px;
  height: 225px;
  background: var(--p);
  z-index: 0;
  position: absolute;
  left: 70px;
  top: 20px;
  box-shadow: inset 0 -2px 10px rgba(0, 0, 0, 0.5);
  border-radius: 300px;
}
#wrap #face .ear {
  position: absolute;
  width: 30px;
  height: 45px;
  background: radial-gradient(circle at right, rgba(0, 0, 0, 0.25) 10px, var(--t) 12.5px), var(--p);
  box-shadow: inset 2px 0px 7.5px rgba(0, 0, 0, 0.5);
  top: 125px;
  z-index: 999;
  left: -7.5px;
  border-radius: 50px 0 0 50px;
  -webkit-mask: linear-gradient(to left, var(--t) 5px, #000 10px);
}
#wrap #face:before, #wrap #face:after {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  border-radius: inherit;
  background: radial-gradient(circle at center, var(--br) 0.5px, var(--t) 0.5px) 0px 0px/5px 5px, radial-gradient(circle at center, var(--br) 0.5px, var(--t) 0.5px) 2.5px 2.5px/5px 5px;
  -webkit-mask: radial-gradient(circle at top right, var(--t) 175px, #000 50px);
}
#wrap #face:after {
  -webkit-mask: linear-gradient(to bottom, #000 40px, var(--t) 40px);
}
#wrap #face .glasses {
  content: "";
  position: absolute;
  width: 100px;
  height: 75px;
  right: -5px;
  top: 75px;
  filter: drop-shadow(0 4px 0 #000) drop-shadow(-1px 0 0 #000) drop-shadow(-2px 0 0 #000);
  z-index: 2;
}
#wrap #face .glasses:after {
  content: "";
  position: absolute;
  width: 50px;
  height: 5px;
  background: #000;
  left: -50px;
  top: 0;
}
#wrap #face .glasses:before {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  background: linear-gradient(to bottom, #000 5px, var(--t) 5px), linear-gradient(to right, #c6ffdd, #fbd786, #f7797d, #fbd786, #c6ffdd, #fbd786, #f7797d, #fbd786, #c6ffdd) 0px 100%/200% 100% no-repeat;
  animation: shine 10s linear infinite;
  clip-path: polygon(0 0, 100% 0, 100% 66%, 83% 42%, 53% 69%, 0 42%);
}
@keyframes shine {
  to {
    background-position: 100% 100%;
  }
}
#wrap #face .nose {
  position: absolute;
  width: 25px;
  height: 40px;
  right: 0px;
  top: 112.5px;
}
#wrap #face .nose:before {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  border-radius: 0 0 100px 100px;
  box-shadow: inset 0 -2px 5px rgba(0, 0, 0, 0.5);
  background: var(--p);
  -webkit-mask: linear-gradient(to bottom, transparent 5px, #000 15px);
  z-index: 2;
}
#wrap #face .nose:after {
  content: "";
  position: absolute;
  width: 60px;
  height: 80px;
  background: linear-gradient(to right, var(--br) 20px, var(--t) 20px, var(--t) calc(100% - 20px), var(--br) calc(100% - 20px)) 50% 0px/100% calc(100% - 25px) no-repeat, radial-gradient(circle at right, var(--br) 20px, var(--t) 12.5px) 50% 10px/100% 100% no-repeat, radial-gradient(circle at left, var(--br) 20px, var(--t) 12.5px) 50% 10px/100% 100% no-repeat;
  left: calc(50% - 30px);
  top: calc(100% - 15px);
  border-radius: 20px 20px 0 0;
}

#pullwrap {
  width: auto;
  height: 300px;
  position: absolute;
  left: 0;
  bottom: 0;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  cursor: grab;
}
#pullwrap:active:before {
  content: "🤏";
  transform: rotate(270deg) scaleX(-1) translate(0px, -5px);
}
#pullwrap:before {
  content: "🫳";
  font-size: 40px;
  position: absolute;
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border-radius: 100%;
  bottom: -7.5px;
  right: -7.5px;
  z-index: 999;
  pointer-events: none;
  transform: rotate(270deg) scaleX(1) translate(-5px, -12.5px);
}

#tophair {
  width: 50px;
  height: calc(100% - 110px);
  position: absolute;
  bottom: 40px;
  left: 0;
  pointer-events: none;
}
#tophair:after {
  content: "";
  position: absolute;
  width: 20px;
  height: 80px;
  left: 50px;
  top: 0;
  background: repeating-linear-gradient(to bottom, var(--br) 0px, var(--br) 5px, var(--dbr) 5px, var(--dbr) 6px) 50% -8px/100% 200%;
  border-radius: 0 20px 20px 0;
}
#tophair:before {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  border-radius: 400px 0px 0 400px;
  background: repeating-radial-gradient(circle at right, var(--br) 0px, var(--br) 5px, var(--dbr) 5px, var(--dbr) 6px) 50% calc(50% - 2px)/100% 100%;
  -webkit-mask: radial-gradient(circle at right, transparent 25px, #000 25px) 50% calc(50% + 10px)/100% 120% no-repeat;
}

#backwrap {
  height: 100px;
  width: 100px;
  transform: rotate(90deg);
}

#hairpull {
  container-type: inline-size;
  width: 400px;
  height: 300px;
  resize: horizontal;
  display: block;
  overflow: hidden;
  position: relative;
  max-width: 500px;
  min-width: 180px;
  transform: rotate(0deg);
}
#hairpull .inner {
  position: absolute;
  width: 100%;
  height: 60px;
  background: repeating-linear-gradient(to bottom, var(--br) 0px, var(--br) 5px, var(--dbr) 5px, var(--dbr) 6px) 50% -1px;
  bottom: 40px;
  right: 0;
  border-radius: 0 400px 0 400px;
}
#hairpull .inner:before, #hairpull .inner:after {
  content: "";
  position: absolute;
  width: 60px;
  height: 60px;
  background: repeating-radial-gradient(circle at left, var(--br) 0px, var(--br) 5px, var(--dbr) 5px, var(--dbr) 6px) calc(50% + 28px) calc(50% + 28px)/200% 200%;
  z-index: 9;
  right: 0;
  top: 0;
  border-radius: 0 100px 0 0;
}
#hairpull .inner:after {
  top: 60px;
  border-radius: 0;
  background: repeating-linear-gradient(to right, var(--br) 0px, var(--br) 5px, var(--dbr) 5px, var(--dbr) 6px) -2px 50%;
  clip-path: polygon(0 0, 100% 0, 100% 44%, 84% 67%, 68% 44%, 54% 67%, 41% 43%, 29% 65%, 11% 42%, 0 66%);
}
@container (min-width: 5px) {
  #hairpull #tophair:after {
    width: calc(150px - 1.25px);
  }
}
@container (min-width: 10px) {
  #hairpull #tophair:after {
    width: calc(150px - 2.5px);
  }
}
@container (min-width: 15px) {
  #hairpull #tophair:after {
    width: calc(150px - 3.75px);
  }
}
@container (min-width: 20px) {
  #hairpull #tophair:after {
    width: calc(150px - 5px);
  }
}
@container (min-width: 25px) {
  #hairpull #tophair:after {
    width: calc(150px - 6.25px);
  }
}
@container (min-width: 30px) {
  #hairpull #tophair:after {
    width: calc(150px - 7.5px);
  }
}
@container (min-width: 35px) {
  #hairpull #tophair:after {
    width: calc(150px - 8.75px);
  }
}
@container (min-width: 40px) {
  #hairpull #tophair:after {
    width: calc(150px - 10px);
  }
}
@container (min-width: 45px) {
  #hairpull #tophair:after {
    width: calc(150px - 11.25px);
  }
}
@container (min-width: 50px) {
  #hairpull #tophair:after {
    width: calc(150px - 12.5px);
  }
}
@container (min-width: 55px) {
  #hairpull #tophair:after {
    width: calc(150px - 13.75px);
  }
}
@container (min-width: 60px) {
  #hairpull #tophair:after {
    width: calc(150px - 15px);
  }
}
@container (min-width: 65px) {
  #hairpull #tophair:after {
    width: calc(150px - 16.25px);
  }
}
@container (min-width: 70px) {
  #hairpull #tophair:after {
    width: calc(150px - 17.5px);
  }
}
@container (min-width: 75px) {
  #hairpull #tophair:after {
    width: calc(150px - 18.75px);
  }
}
@container (min-width: 80px) {
  #hairpull #tophair:after {
    width: calc(150px - 20px);
  }
}
@container (min-width: 85px) {
  #hairpull #tophair:after {
    width: calc(150px - 21.25px);
  }
}
@container (min-width: 90px) {
  #hairpull #tophair:after {
    width: calc(150px - 22.5px);
  }
}
@container (min-width: 95px) {
  #hairpull #tophair:after {
    width: calc(150px - 23.75px);
  }
}
@container (min-width: 100px) {
  #hairpull #tophair:after {
    width: calc(150px - 25px);
  }
}
@container (min-width: 105px) {
  #hairpull #tophair:after {
    width: calc(150px - 26.25px);
  }
}
@container (min-width: 110px) {
  #hairpull #tophair:after {
    width: calc(150px - 27.5px);
  }
}
@container (min-width: 115px) {
  #hairpull #tophair:after {
    width: calc(150.........完整代码请登录后点击上方下载按钮下载查看

网友评论0