CSS做一个小黄人

原发明人的文章:http://mp.weixin.qq.com/s?__biz=MjM5OTA1MDUyMA==&mid=210492428&idx=2&sn=c3581ceac502efe70396c42adc8cf3f0&scene=1&srcid=KXmyGTvQ7tPviFLp52fo&key=dffc561732c226518cdc1384523b0b9a18f770a8ddd8f6956606a22ccff5e3a6a2c5c32c6d221042ec189adaf13b23e2&ascene=1&uin=MTk3NDUxODAw&devicetype=Windows+10&version=6102002a&pass_ticket=4M5mMBQNEsyaIhmPcSR%2FXDAQ4Gky5nfNZsKjNUFionQ%3D

原发明人的源代码:https://github.com/JR93/littleHuang

我的代码,完成了基本部分,并且合并了html和css,加了我自己的注释,可以复制到http://www.zaole.net/查看效果:

                <!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title></title>
    <style>
      body{
        /*background-color:white;*/
        margin:0;
        padding:0;
      }
      /*以下是1身体*/
      .wrapper{
        width:300px;
        margin:100px auto;
      }
      .littleH{
        position:relative;/*用于给子层定位*/
      }
      .bodyH{
        position:absolute;
        width:240px;
        height:400px;
        border:5px solid #000;
        border-radius:115px;
        background:rgb(249,217,70);
        overflow:hidden;
        z-index:2;
      }
      /*以下是2裤子*/
      .bodyH .trousers{/*注意中间的空格*/
        position:absolute;
        bottom:0;
        width:100%;
        height:100px;
        border-top: 6px solid #000;
        background:rgb(32,116,160);
      }
      .bodyH .trousers_top{
        width:160px;
        height:60px;
        border:6px solid #000;
        border-bottom:none;
        border-radius:0 0 5px 5px;
        background:rgb(32,116,160);
        position:absolute;
        bottom:100px;
        left:34px;
      }
      /*以下是3吊带*/
      .bodyH .condoleBelt{
        position:absolute;
      }
      .bodyH .condoleBelt .left,
      .bodyH .condoleBelt .right{
        width:100px;
        height:16px;
        border:5px solid #000;
        background:rgb(32,116,160);
        position:absolute;
        top:-90px;
        left:-35px;
        z-index:2;
        -webkit-transform:rotate(45deg);
      }
      .bodyH .condoleBelt .left{
        top:-88px;
        left:165px;
        -webkit-transform:rotate(-45deg);
      }
      .bodyH .condoleBelt .left:after,
      .bodyH .condoleBelt .right:after{
        content: '';
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: #000;
        position: absolute;
        top:4px;
        left:88px;
      }
      .bodyH .condoleBelt .left:after{
  left:5px;
      }
      /*以下是4裤袋*/
      .pocket{
        width:60px;
        height:45px;
        border:6px solid #000;
        border-radius: 0px 0px 25px 25px;
        position: absolute;
        bottom:65px;
        left:84px;
      }
      .line_right{
       width: 30px;
        height: 30px;
        border-bottom-left-radius:100px;
        border-bottom:6px solid #000;
        border-left:6px solid #000;
        position:absolute;
        left:0;
        bottom:60px;
        -webkit-transform:rotate(-75deg);
      }
      .line_left{
        width: 30px;
        height: 30px;
        border-bottom-right-radius: 100px;
        border-bottom:6px solid #000;
        border-right:6px solid #000;
        position: absolute;
        right: 0;
        bottom:63px;
        -webkit-transform:rotate(75deg);
      }
      .line_bottom{
        height: 40px;
        border:3px solid #000;
        border-radius: 3px;
        position: absolute;
        left:118px;
        bottom: 0px;
      }
      /*以下是5眼睛*/
      .eyes{
        position:relative;
        z-index:3;
      }
      .eyes .leftEye, .eyes .rightEye{
        width:85px;
        height:85px;
        position:absolute;
        background:#fff;
        border-radius:50%;
        border:6px solid #000;
        top:60px;
        left:27px;
      }
      .eyes .rightEye{
        left:124px;
      }
      .eyes .leftEye .left_blackEye,
      .eyes .rightEye .right_blackEye{
        width:40px;
        height:40px;
        border-radius:50%;
        background:#000;
        position:absolute;
        top:24px;
        left:22px;
        -webkit-animation:blackeye 5s ease-in infinite;
      }
      @-webkit-keyframes blackeye{
        0%,20%,50%,70%,100%{
          -webkit-transform:translateX(0px);
        }
        30%,40%{
         -webkit-transform:translateX(15px);
        }
        80%,90%{
         -webkit-transform:translateX(-15px);
        }
      }
      .eyes .leftEye .left_blackEye .left_white,
      .eyes .rightEye .right_blackEye .right_white{
        width:20px;
        height:20px;
        border-radius:50%;
        background:#fff;
        position:absolute;
        top:7px;
        left:17px;
        -webkit-animation:whiteeye 5s ease-in-out infinite;
      }
      @-webkit-keyframes whiteeye{
        0%,20%,50%,70%,100%{
          -webkit-transform:translateX(0px);
        }
        30%,40%{
          -webkit-transform:translate3d(3px,4px,0);
        }
        80%,90%{
          -webkit-transform:translate3d(-15px,4px,0);
        }
      }
      .eyes .leftEye .left_blackEye .left_white{
        top:4px;
        left:17px;
      }
      .eyes .leftEye:after,
      .eyes .rightEye:after{
        content: '';
        background:#000;
        position:absolute;
        width:28px;
        height:18px;
        left:-30px;
        top:37px;
        -webkit-transform:skewX(20deg) rotate(7deg);
      }
      .eyes .rightEye:after{
        left:89px;
        top:37px;
        -webkit-transform:skewX(-20deg) rotate(-7deg);
      }
      /*以下是6嘴巴*/
      .mouse{
        position: relative;
      }
      .mouse .mouse_shape{
        width:55px;
        height:35px;
        border:5px solid #000;
        border-bottom-left-radius: 30px;
        background: #fff;
        position: absolute;
        top:175px;
        left:98px;
        z-index:3;
        -webkit-transform:rotate(-35deg);
      }
    </style>
  </head>
  <body>
 <div class="wrapper"><!-- 容器 -->
      <div class="littleH"><!-- 小黄人 -->
      <div class="bodyH"><!-- 身体 -->
         <div class="trousers"><!-- 裤子 -->
             <div class="condoleBelt"><!-- 吊带 -->
                 <div class="left"></div>
                 <div class="right"></div>
             </div>
             <div class="trousers_top"></div>
           <!-- 裤子突出的矩形部分 -->
             <div class="pocket"></div><!-- 裤袋 -->
             <!-- 三条线 -->
             <span class="line_left"></span>
             <span class="line_right"></span>
             <span class="line_bottom"></span>
         </div>
      </div>
      <div class="hair"><!-- 头发 -->
         <span class="left_hair_one"></span>
         <span class="left_hair_two"></span>
      </div>
      <div class="eyes"><!-- 眼睛 -->
         <div class="leftEye"><!-- 左眼 -->
             <div class="left_blackEye">
                 <div class="left_white"></div>
             </div>
         </div>
         <div class="rightEye"><!-- 右眼 -->
             <div class="right_blackEye">
                 <div class="right_white"></div>
             </div>
         </div>
      </div>
      <div class="mouse"><!-- 嘴巴 -->
         <div class="mouse_shape"></div>
      </div>
      <div class="hands"><!-- 双手 -->
         <div class="leftHand"></div>
         <div class="rightHand"></div>
      </div>
      <div class="feet"><!-- 双脚 -->
         <div class="left_foot"></div>
         <div class="right_foot"></div>
      </div>
      <div class="groundShadow"></div><!-- 脚底阴影 -->
      </div>
 </div>
  </body>
</html>

               

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值