div+css实现一个会眨眼睛的黏土人物形象代码

代码语言:html

所属分类:布局界面

代码描述:div+css实现一个会眨眼睛的黏土人物形象代码

代码标签: div css 眨眼睛 黏土 人物 形象 代码

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

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

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

  
  
<style>
/*
Drawing inspired by the cartoon on this tweet:
https://twitter.com/charca/status/1845577967180947875
*/
body {
  overflow: clip;
}

article {
  --center: 45%;

  /* colors */
  --shirt: #e4ce61;
  --skin: #ddb88e;
  --feature: #333;
  --hair: #ee9247;
  --pants: #6ca1ba;

  /* color alternative */
/*     --shirt: #c83;
  --skin: #753;
  --feature: #333;
  --hair: #321;
  --pants: #696; */

  /* color alternative */
/*     --shirt: #eee;
  --skin: #fdb;
  --feature: #333;
  --hair: #c9c;
  --pants: #369; */

  font-size: 1vmin;
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translate(-50%, 0%);
  width: 80em;
  aspect-ratio: 1;
  overflow: hidden;
}

article *,
article *::before,
article *::after {
  position: absolute;
  box-sizing: border-box;
}

.pants {
  width: 30%;
  height: 20%;
  bottom: 0;
  left: var(--center);
  transform: translate(-50%);
  border-radius: 40% / 120% 120% 0 0;
  box-shadow: 
    inset 0 1em 1em #0003;
  background: 
    linear-gradient(182deg, #0003 30%, #0000 40%),
    linear-gradient(85deg, #ffffff18, #0000 60%, #0002 90%, #0001 0, #0000) 60% 0 / 12% 100% no-repeat,
    linear-gradient(90deg,#0001, #0000, #0001 40%, #0002 50%, #0003),
    var(--pants); 
}

.shirt-back {
  left: var(--center);
  top: 52%;
  width: 15%;
  height: 20%;
  background: var(--shirt);
  box-shadow: 
    inset 0 0 0.25em var(--shirt),
    inset 0 0 0 9em #0003;
  translate:-50% 0;
}

.shirt {
  width: var(--center);
  height: 35%;
  bottom: 14%;
  left: var(--center);
  transform: translate(-50%);
  -webkit-mask: radial-gradient(20% 10% at 50% 0, #0000 90%, #000 0);
  mask: radial-gradient(20% 10% at 50% 0, #0000 90%, #000 0);


  &::before {
    content: "";
    width: 100%;
    height: 100%;
    box-shadow: inset 0 -1em 2em #0001;
    border-radius: 100% / 100% 100% 20% 20%;
    -webkit-mask:
      radial-gradient(54% 80% at 10% 60%, #0000 70%, #000 0) 0 0 / 55% 100% no-repeat,
      radial-gradient(54% 80% at 90% 60%, #0000 70%, #000 0) 100% 0 / 55% 100% no-repeat;
    mask:
      radial-gradient(54% 80% at 10% 60%, #0000 70%, #000 0) 0 0 / 55% 100% no-repeat,
      radial-gradient(54% 80% at 90% 60%, #0000 70%, #000 0) 100% 0 / 55% 100% no-repeat;
    background: 
      radial-gradient(6% 25% at 76% 0, #00000018 50%, #0000),
      radial-gradient(40% 30% at 50% 25%, var(--shirt), #fff0),
      radial-gradient(farthest-side at 0 0, #0000 20%, #0001),
      radial-gradient(54% 80% at 10% 75%, #fff4 30%, #0000) 0 0 / 55% 100% no-repeat,
      radial-gradient(54% 80% at 10% 75%, var(--shirt) 60%, #0000) 0 0 / 55% 100% no-repeat,
      radial-gradient(54% 80% at 90% 75%, #0002 50%, #0000) 100% 0 / 55% 100% no-repeat,
      linear-gradient(#0000, #00000008 40%, #00000008 60%, #0000) 100% 0 / 80% 100% no-repeat,
      radial-gradient(150% 80% at 0% 100%, #0000 20%, #0000000a 60%, #0000) 100% 0 / 100% 100% no-repeat,
      var(--shirt);

  }
}

.shirt-arm {
  --x: ;
  width: 17%;
  height: 17%;
  top: 54.75%;
  left: calc(var(--center) - 24%);
  border-radius: 110% 0 0 0;
  clip-path: polygon(0 0, 100% 0, 100% 50%, 50% 90%, 0 40%);
  transform: rotate(-16deg);
  box-shadow: inset 1em 0.4em 1em #fff2;
  background:
    var(--x)
    radial-gradient(120% 110% at 0 10%, #0000 65%, #0003),
    linear-gradient(-45deg, #0002, #0000 50%)
    var(--shirt);

  & ~ & {
    --x: linear-gradient(#00000017 0 0),;
    transform: scaleX(-1) rotate(-16deg);
    left: calc(var(--center) + 7%);
    box-shadow: none;
  }
}

.arm {
  --a: 195deg;
  --x:  #fff3;
  width: 20%;
  height: 50%;
  top: 60%;
  left: calc(var(--center) - 25.5%);
  transform: rotate(10deg);
  border-radius: 50% /100% 0 0 100%;
  -webkit-mask: radial-gradient(60% 70% at 90% 60%, #0000 99%, #000);
  mask: radial-gradient(60% 70% at 90% 60%, #0000 99%, #000);
  box-shadow: 
    inset -4em 7em 1em #0002,
    inset 0.5em 0.5em 0.5em #0001,
    inset 1em 1em 1em var(--x);
  background: 
    linear-gradient(var(--a), #a004, #0000 25%),
    radial-gradient(90% 80% at 90% 60%, #0002 75%, #0001 85%, #0000),
    var(--skin);

  & ~ & {
    --a: 198deg;
    --x:  #0001;
    left: calc(var(--center) + 5.4%);
    transform: scaleX(-1) rotate(10deg);
  }
}

.neck {
  left: var(--center);
  top: 44%;
  width: 16%;
  height: 13%;
  transform: translate(-50%);
  background: #f004;
  -webkit-mask: 
    radial-gradient(50% 62% at 0 100%, #0000 99%, #000) 0 0 / 55% 32% no-repeat,
    radial-gradient(50% 65% at 100% 100%, #0000 99%, #000) 100% 0 / 55% 32% no-repeat,
    radial-gradient(50% 50% at 0 0, #0000 99%, #000) 0 100% / 55% 70% no-repeat,
    radial-gradient(50% 50% at 100% 0, #0000 99%, #000) 100% 100% / 55% 70% no-repeat;
  mask: 
    radial-gradient(50% 62% at 0 100%, #0000 99%, #000) 0 0 / 55% 32% no-repeat,
    radial-gradient(50% 65% at 100% 100%, #0000 99%, #000) 100% 0 / 55% 32% no-repeat,
    radial-gradient(50% 50% at 0 0, #0000 99%, #000) 0 100% / 55% 70% no-repeat,
    radial-gradient(50% 50% at 100% 0, #0000 99%, #000) 100% 100% / 55% 70% no-repeat;
  background:
    radial-gradient(50% 60% at 10% 80%, #7002, #0000),
    radial-gradient(50% 60% at 90% 40%, #6002, #0000),
    radial-gradient(80% 90% at 50% 0, #0000 80%, #0002),
    radial-gradient(40% 80% at 50% 100%, #0000 80%, #00000015),
    var(--skin);
}

.head {
  left: var(--center);
  top: 17%;
  width: 30%;
  height: 30%;
  transform: translate(-50%) rotate(10deg);
  box-shadow:
    /* hair shadow */
    inset 3em -0.5em 1em -2em #3001,
    inset 3.5em -0.5em 2em -1.4em #3002,
    inset -3.5em 0.5em 1em -2em #3002,

    inset 1em 0em 1em #5001,
    inset 3em 1em 2em #fff3
    ;
  background: #f004;
  border-radius: 100% 30% 100% 40% / 30% 100% 40% 100%;
  background:
    /* hair shadow*/
    radial-gradient(37% 27% at 100% 0, #0001 90%, #0000),
    radial-gradient(85% 40% at -12% 0, #5002 90%, #0000),

    radial-gradient(150% 95% at 0 0, #0000 80%, #0001),
    linear-gradient(90deg, #0000, #fff1, #0000, #0001, #0002),
    var(--skin);
}


@keyframes blink {
  0%, 2%, 100% { transform: rotate(-10deg) translate(-50%) scaleY(1); }
  1% { transform: rotate(-10deg) translate(-50%) scaleY(0); }
}

.eye {
  --p: 30%;
  --c: #0000;
  --s: 1;
  width: 10%;
  height: 13%;
  top: 45%;
  left: var(--p);
  border-radius: 50%;
  box-shadow:
    inset.........完整代码请登录后点击上方下载按钮下载查看

网友评论0