纯CSS3打造属于自己的“小黄人”

效果就像这样:

不废话,直接上代码!

hrml代码:

XML/HTML Code复制内容到剪贴板 <!DOCTYPE html>   <html>   <head lang="zh">       <meta charset="UTF-8">       <title>纯CSS3画出小黄人并实现动画效果</title>       <Link href="index.css" type="text/css" rel="stylesheet" />   </head>   <body>       <!--容器-->       <div class="wrapper">           <!--小黄人-->           <div class="container">               <!--头发-->               <div class="hairs">                   <div class="hairs_one"></div>                   <div class="hairs_two"></div>               </div>               <!--头发-->               <!--眼睛-->               <div class="eyes">                   <div class="eye_left">                       <div class="black">                           <div class="white"></div>                       </div>                   </div>                   <div class="eye_right">                       <div class="black">                           <div class="white"></div>                       </div>                   </div>               </div>               <!--眼睛-->               <!--嘴巴-->               <div class="mouth">                   <div class="mouth_box"></div>               </div>               <!--嘴巴-->               <!--手-->               <div class="hands">                   <div class="left_hand"></div>                   <div class="right_hand"></div>               </div>               <!--手-->               <!--身体-->               <div class="mybody">                   <!--裤子-->                   <div class="trousers">                       <!--裤子突出部分-->                       <div class="trousers_top"></div>                       <!--裤子口袋-->                       <div class="pocket"></div>                       <!--三角线-->                       <div class="line-left"></div>                       <div class="line-right"></div>                       <div class="line-bottom"></div>                       <!--吊带-->                       <div class="condoleBelt">                           <div class="left"></div>                           <div class="right"></div>                       </div>                   </div>                   <!--裤子-->               </div>               <!--身体-->               <!--脚-->               <div class="foot">                   <div class="left_foot"></div>                   <div class="right_foot"></div>               </div>               <!--脚-->               <!--阴影-->               <div class="foot_shadow"></div>               <!--阴影-->           </div>       </div>   </body>   </html>    

css代码:

CSS Code复制内容到剪贴板 body {      margin: 0;      padding: 0;    }    .wrapper {      width300px;      margin100px auto;    }    .container {      positionrelative;    }    .container .mybody {      positionabsolute;      width240px;      height400px;      border5px solid #000;      border-radius: 115px;      background#f9d946;      overflowhidden;      z-index: 2;    }    .container .mybody .trousers {      positionabsolute;      bottombottom: 0;      width: 100%;      height100px;      border-top6px solid #000;      background#2074a0;    }    .container .mybody .trousers .trousers_top {      width160px;      height60px;      background#2074a0;      positionabsolute;      bottombottom100px;      left: 0;      rightright: 0;      margin: 0 auto;      border6px solid #000;      border-bottomnone;    }    .container .mybody .trousers .pocket {      width60px;      height45px;      border6px solid #000;      border-radius: 0 0 25px 25px;      left: 0;      rightright: 0;      margin: 0 auto;      positionabsolute;      bottombottom65px;    }    .container .mybody .trousers .line-left,    .container .mybody .trousers .line-rightright {      width30px;      height30px;      border-bottom-rightright-radius: 100px;      border-right6px solid;      border-bottom6px solid;      positionabsolute;      top10px;    }    .container .mybody .trousers .line-rightright {      rightright: 0;      -webkit-transform: rotate(75deg);      -moz-transform: rotate(75deg);      -o-transform: rotate(75deg);      transform: rotate(75deg);      -ms-transform: rotate(75deg);    }    .container .mybody .trousers .line-bottombottom {      height40px;      border3px solid #000;      left118px;      positionabsolute;      bottombottom: 0;      border-radius: 3px;    }    .container .mybody .trousers .condoleBelt {      positionabsolute;    }    .container .mybody .trousers .condoleBelt .left,    .container .mybody .trousers .condoleBelt .rightright {      width100px;      height16px;      border5px solid #000;      background#2074a0;      top: -90px;      positionabsolute;    }    .container .mybody .trousers .condoleBelt .left:after,    .container .mybody .trousers .condoleBelt .rightright:after {      content;      background#000;      width8px;      height8px;      border-radius: 50%;      positionabsolute;      top3px;    }    .container .mybody .trousers .condoleBelt .left {      left: -35px;      transform: rotate(45deg);    }    .container .mybody .trousers .condoleBelt .left:after {      rightright3px;    }    .container .mybody .trousers .condoleBelt .rightright {      transform: rotate(-45deg);      left165px;    }    .container .mybody .trousers .condoleBelt .rightright:after {      left3px;    }    .container .hairs {      positionrelative;    }    .container .hairs .hairs_one {      width130px;      height100px;      border-top8px solid #000;      positionabsolute;      transform: rotate(35deg);      left24px;      top: -17px;      border-radius: 50%;      animation: hairs 2s ease-in-out infinite;    }    .container .hairs .hairs_two {      width80px;      height80px;      border-top6px solid #000;      positionabsolute;      transform: rotate(15deg);      left50px;      top: -10px;      border-radius: 50%;    }    .container .eyes {      positionrelative;      z-index: 3;    }    .container .eyes .eye_left,    .container .eyes .eye_right {      width85px;      height85px;      border6px solid #000;      border-radius: 50%;      background#fff;      positionabsolute;      top60px;    }    .container .eyes .eye_left:after,    .container .eyes .eye_right:after {      content;      width28px;      height18px;      background#000;      positionabsolute;      top: 40%;    }    .container .eyes .eye_left {      left27px;    }    .container .eyes .eye_left:after {      left: -30px;      transform: rotate(7deg) skewX(20deg);    }    .container .eyes .eye_right {      left124px;    }    .container .eyes .eye_right:after {      rightright: -32px;      transform: rotate(-7deg) skewX(-20deg);    }    .container .eyes .black {      width40px;      height40px;      background#000;      border-radius: 50%;      positionabsolute;      top24px;      left22px;      animation: eys_black 5s ease-in-out infinite;    }    .container .eyes .white {      width20px;      height20px;      background#fff;      border-radius: 50%;      positionabsolute;      top10px;      left10px;      animation: eys_white 5s ease-in-out infinite;    }    .container .mouth {      positionrelative;      z-index: 3;    }    .container .mouth .mouth_box {      positionabsolute;      width55px;      height35px;      border5px solid #000;      background#fff;      top170px;      left90px;      border-bottom-left-radius: 30px;      transform: rotate(-35deg);      animation: mouth_box 5s ease-in-out infinite;    }    .container .mouth .mouth_box:after {      background#f9d946;      width70px;      height32px;      content;      positionabsolute;      border-bottom5px solid #000;      transform: rotate(35deg);      top: -14px;      left6px;      animation: mouth_after 5s ease-in-out infinite;    }    .container .hands {      positionrelative;      z-index: 1;    }    .container .hands .left_hand,    .container .hands .right_hand {      width80px;      height80px;      border6px solid #000;      transform: rotate(40deg);      positionabsolute;      background#f9d946;      border-radius: 30px;      top220px;      animation: left_hand 1s ease-in-out infinite;    }    .container .hands .left_hand {      left: -24px;    }    .container .hands .left_hand:after {      width6px;      border3px solid #000;      positionabsolute;      content;      transform: rotate(90deg);      bottombottom26px;      left12px;    }    .container .hands .right_hand {      rightright26px;    }    .container .hands .right_hand:after {      width6px;      border3px solid #000;      positionabsolute;      content;      top20px;      rightright18px;    }    .container .foot {      positionrelative;    }    .container .foot .left_foot,    .container .foot .right_foot {      width36px;      height50px;      background#000;      positionabsolute;      top400px;    }    .container .foot .left_foot:after,    .container .foot .right_foot:after {      width60px;      height35px;      positionabsolute;      bottombottom: 0;      content;      background#000;    }    .container .foot .left_foot {      left86px;      animation: left_foot 1s ease-in-out infinite;    }    .container .foot .left_foot:after {      rightright: 0;      top20px;      border-radius: 30px 0 10px 20px;    }    .container .foot .right_foot {      left128px;      animation: right_foot 1s ease-in-out infinite;    }    .container .foot .right_foot:after {      left: 0;      top20px;      border-radius: 0 30px 20px 10px;    }    .container .foot_shadow {      positionabsolute;      top456px;      width240px;      height纯CSS3打造属于自己的“小黄人”