纯css打造超能陆战队--大白

纯css打造超能陆战队–大白

要点 思路

要把大白分割,整体baymax中包含header(eye1,eye2,mouth),torso(heart),belly(cover),l-bigfinger,r-bigfinger,l-smallfinger,r-smallfinger,l-leg,r-leg。

代码

<!DOCTYPE html>
<html>
     <head>
           <meta charset="UTF-8">
           <title></title>
           <style>
           body{background: #595959;}
                #baymax{
                      margin: 0 auto;
                     height: 600px;
                }
                #head{
                     height: 64px;
                width: 100px;
                     background-color: white;
                     border-radius: 50%;
                     margin: 0 auto;
                      margin-bottom: -20px;
                     border-bottom: 5px solid #E0E0E0;
                     z-index: 100;
    /*生成相对定位的元素*/
                   position: relative;
                }
                #eye1{
                     width: 15px;
                     height: 15px;
                     background: black;
                     border-radius: 50%;
                     position: absolute;
                     left: 20px;
                     top: 20px;
                     transform: rotate(8deg);
                }
                #eye2{
                     width: 15px;
                     height: 15px;
                     background: black;
                     border-radius: 50%;
                     position: absolute;
                     transform: rotate(-8deg);
                left: 60px;
                 top: 20px;
                }
                #mouth{
                     width: 40px;
                     height: 2px;
                     background: black;
                     position: absolute;
                     left: 30px;
                     top: 27px;
                     
                }
                #torso,#belly{
                     width: 150px;
                     height: 180px;
                     margin: 0 auto;
                     background: white;
                     border-radius: 45%;
                     border: 5px solid #DCDCDC;
                     border-top: none ;
                     z-index:1;
                }
                
                #belly{
                     width: 200px;
                     height: 240px;
                     margin-top: -145px;
                     position: relative;
                     z-index: 5;
                     }
                #cover{
                     width: 180px;
                     height: 250px;
                     margin: 0 auto;
                     background: white;
                     border-radius: 47%;
                     position: relative;
                    top:-20px ;
                     }
                #heart{
                     width: 20px;
                     height:20px;
                     border-radius: 50%;
                     background: white;
                     border: 1px solid #DCDCDC;
                     box-shadow:2px 5px 2px #ccc inset;
                     margin: 0 auto;
                     z-index: 111;
                     position: relative;
                    right:-40px;
                top:50px;
                     
                }
                #left-arm,#right-arm{
                     width: 80px;
                     height: 220px;
                     margin: 0 auto;
                     background: white;
                     border-radius: 47%;
                     transform:rotate(23deg);
                     position: relative;
                     top: -270px;
                     left: -95px;
                }
                #right-arm{
                     transform:rotate(-23deg);
                     position: relative;
                     top: -490px;
                     left: 95px;
                }
                #l-bigfinger{
                     width: 20px;
                     height: 60px;
                     margin: 0 auto;
                     background: white;
                     border-radius: 47%;
                     transform:rotate(125deg);
                     position: absolute;
                     top: 190px;
                     left:35px;
                }
                #l-smallfinger{
                width: 15px;
                     height: 40px;
                     margin: 0 auto;
                     background: white;
                     border-radius: 47%;
                     transform:rotate(125deg);
                     position: absolute;
                     top: 190px;
                     left:52px; 
                }
                
                #r-smallfinger{
                     width: 15px;
                     height: 40px;
                     margin: 0 auto;
                     background: white;
                     border-radius: 47%;
                     transform:rotate(-125deg);
                     position: absolute;
                     top: 190px;
                     left:12px;
                }
                #r-bigfinger{
                     width: 20px;
                     height: 60px;
                     margin: 0 auto;
                     background: white;
                     border-radius: 47%;
                     transform:rotate(-125deg);
                     position: absolute;
                     top: 190px;
                     left:25px;
                }
                #left-leg{
                     width: 75px;
                     height: 150px;
                     margin: 0 auto;
                     background: white;
                     border-radius: 47%;
                     position: relative;
                     left: -40px;
                     top: -500px;
                     border-bottom-right-radius: 15%;
                }
                #right-leg{
                     width: 75px;
                     height: 150px;
                     margin: 0 auto;
                     background: white;
                     border-radius: 47%;
                     position: relative;
                     left: 40px;
                     top: -650px;
                     border-bottom-left-radius: 15%;
                }
                
           </style>
     </head>
     <body>
           <div id="baymax">
           <div id="head">
                <div id="eye1"></div>
                <div id="eye2"></div>
                <div id="mouth"></div>
           </div>
           <div id="torso">
                <div id="heart"></div>
           </div>
           <div id="belly">
                <div id="cover"></div>
           </div>
           <div id="left-arm">
                <div id="l-bigfinger"></div>
                <div id="l-smallfinger"></div>
           </div>
           <div id="right-arm">
                <div id="r-bigfinger"></div>
                <div id="r-smallfinger"></div>
           </div>
           <div id="left-leg"></div>
           <div id="right-leg"></div>
     </div>     
     </body>
</html>

效果图
在这里插入图片描述

注意

  1. 因为大白是白色,所以背景颜色(body)要设为深色。

  2. 大白居中,div居中要用margin:0 auto;

  3. 保险起见overflow:hidden

总结head文件的规范:
1.设置宽高之后以百分比定义圆角的形状 border-radius:50%
2.margin-bottom设为负值,使身体与头部有重叠
3.因为只有设置了position 为relative absolute fixed 后 ,设置z-index才生效。并且z-index是相对于同一父亲元素的所有子元素的层级关系,z-index的值越大,说明他的位置越高。
所以给头部设置position:relative,然后将层级z-index:100
其次写eye1,eye2:
用到旋转对称使左右眼对称,transform:rotate(**deg)与transform:rotate(-**deg)左右对称,左右手臂,左右手指,左右腿都会用到。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值