效果就像这样:
不废话,直接上代码!
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 {
- width: 300px;
- margin: 100px auto;
- }
- .container {
- position: relative;
- }
- .container .mybody {
- position: absolute;
- width: 240px;
- height: 400px;
- border: 5px solid #000;
- border-radius: 115px;
- background: #f9d946;
- overflow: hidden;
- z-index: 2;
- }
- .container .mybody .trousers {
- position: absolute;
- bottombottom: 0;
- width: 100%;
- height: 100px;
- border-top: 6px solid #000;
- background: #2074a0;
- }
- .container .mybody .trousers .trousers_top {
- width: 160px;
- height: 60px;
- background: #2074a0;
- position: absolute;
- bottombottom: 100px;
- left: 0;
- rightright: 0;
- margin: 0 auto;
- border: 6px solid #000;
- border-bottom: none;
- }
- .container .mybody .trousers .pocket {
- width: 60px;
- height: 45px;
- border: 6px solid #000;
- border-radius: 0 0 25px 25px;
- left: 0;
- rightright: 0;
- margin: 0 auto;
- position: absolute;
- bottombottom: 65px;
- }
- .container .mybody .trousers .line-left,
- .container .mybody .trousers .line-rightright {
- width: 30px;
- height: 30px;
- border-bottom-rightright-radius: 100px;
- border-right: 6px solid;
- border-bottom: 6px solid;
- position: absolute;
- top: 10px;
- }
- .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 {
- height: 40px;
- border: 3px solid #000;
- left: 118px;
- position: absolute;
- bottombottom: 0;
- border-radius: 3px;
- }
- .container .mybody .trousers .condoleBelt {
- position: absolute;
- }
- .container .mybody .trousers .condoleBelt .left,
- .container .mybody .trousers .condoleBelt .rightright {
- width: 100px;
- height: 16px;
- border: 5px solid #000;
- background: #2074a0;
- top: -90px;
- position: absolute;
- }
- .container .mybody .trousers .condoleBelt .left:after,
- .container .mybody .trousers .condoleBelt .rightright:after {
- content: '';
- background: #000;
- width: 8px;
- height: 8px;
- border-radius: 50%;
- position: absolute;
- top: 3px;
- }
- .container .mybody .trousers .condoleBelt .left {
- left: -35px;
- transform: rotate(45deg);
- }
- .container .mybody .trousers .condoleBelt .left:after {
- rightright: 3px;
- }
- .container .mybody .trousers .condoleBelt .rightright {
- transform: rotate(-45deg);
- left: 165px;
- }
- .container .mybody .trousers .condoleBelt .rightright:after {
- left: 3px;
- }
- .container .hairs {
- position: relative;
- }
- .container .hairs .hairs_one {
- width: 130px;
- height: 100px;
- border-top: 8px solid #000;
- position: absolute;
- transform: rotate(35deg);
- left: 24px;
- top: -17px;
- border-radius: 50%;
- animation: hairs 2s ease-in-out infinite;
- }
- .container .hairs .hairs_two {
- width: 80px;
- height: 80px;
- border-top: 6px solid #000;
- position: absolute;
- transform: rotate(15deg);
- left: 50px;
- top: -10px;
- border-radius: 50%;
- }
- .container .eyes {
- position: relative;
- z-index: 3;
- }
- .container .eyes .eye_left,
- .container .eyes .eye_right {
- width: 85px;
- height: 85px;
- border: 6px solid #000;
- border-radius: 50%;
- background: #fff;
- position: absolute;
- top: 60px;
- }
- .container .eyes .eye_left:after,
- .container .eyes .eye_right:after {
- content: '';
- width: 28px;
- height: 18px;
- background: #000;
- position: absolute;
- top: 40%;
- }
- .container .eyes .eye_left {
- left: 27px;
- }
- .container .eyes .eye_left:after {
- left: -30px;
- transform: rotate(7deg) skewX(20deg);
- }
- .container .eyes .eye_right {
- left: 124px;
- }
- .container .eyes .eye_right:after {
- rightright: -32px;
- transform: rotate(-7deg) skewX(-20deg);
- }
- .container .eyes .black {
- width: 40px;
- height: 40px;
- background: #000;
- border-radius: 50%;
- position: absolute;
- top: 24px;
- left: 22px;
- animation: eys_black 5s ease-in-out infinite;
- }
- .container .eyes .white {
- width: 20px;
- height: 20px;
- background: #fff;
- border-radius: 50%;
- position: absolute;
- top: 10px;
- left: 10px;
- animation: eys_white 5s ease-in-out infinite;
- }
- .container .mouth {
- position: relative;
- z-index: 3;
- }
- .container .mouth .mouth_box {
- position: absolute;
- width: 55px;
- height: 35px;
- border: 5px solid #000;
- background: #fff;
- top: 170px;
- left: 90px;
- border-bottom-left-radius: 30px;
- transform: rotate(-35deg);
- animation: mouth_box 5s ease-in-out infinite;
- }
- .container .mouth .mouth_box:after {
- background: #f9d946;
- width: 70px;
- height: 32px;
- content: '';
- position: absolute;
- border-bottom: 5px solid #000;
- transform: rotate(35deg);
- top: -14px;
- left: 6px;
- animation: mouth_after 5s ease-in-out infinite;
- }
- .container .hands {
- position: relative;
- z-index: 1;
- }
- .container .hands .left_hand,
- .container .hands .right_hand {
- width: 80px;
- height: 80px;
- border: 6px solid #000;
- transform: rotate(40deg);
- position: absolute;
- background: #f9d946;
- border-radius: 30px;
- top: 220px;
- animation: left_hand 1s ease-in-out infinite;
- }
- .container .hands .left_hand {
- left: -24px;
- }
- .container .hands .left_hand:after {
- width: 6px;
- border: 3px solid #000;
- position: absolute;
- content: '';
- transform: rotate(90deg);
- bottombottom: 26px;
- left: 12px;
- }
- .container .hands .right_hand {
- rightright: 26px;
- }
- .container .hands .right_hand:after {
- width: 6px;
- border: 3px solid #000;
- position: absolute;
- content: '';
- top: 20px;
- rightright: 18px;
- }
- .container .foot {
- position: relative;
- }
- .container .foot .left_foot,
- .container .foot .right_foot {
- width: 36px;
- height: 50px;
- background: #000;
- position: absolute;
- top: 400px;
- }
- .container .foot .left_foot:after,
- .container .foot .right_foot:after {
- width: 60px;
- height: 35px;
- position: absolute;
- bottombottom: 0;
- content: '';
- background: #000;
- }
- .container .foot .left_foot {
- left: 86px;
- animation: left_foot 1s ease-in-out infinite;
- }
- .container .foot .left_foot:after {
- rightright: 0;
- top: 20px;
- border-radius: 30px 0 10px 20px;
- }
- .container .foot .right_foot {
- left: 128px;
- animation: right_foot 1s ease-in-out infinite;
- }
- .container .foot .right_foot:after {
- left: 0;
- top: 20px;
- border-radius: 0 30px 20px 10px;
- }
- .container .foot_shadow {
- position: absolute;
- top: 456px;
- width: 240px;
- height: 2px;
- background: rgba(0, 0, 0, 0.3);
- box-shadow: 0 0 2px 4px rgba(0, 0, 0, 0.3);
- border-radius: 50%;
- }
- @keyframes hairs {
- 30% {
- transform: rotate(32deg) translate3d(-4px, -2px, 0);
- }
- }
- @keyframes eys_black {
- 0% {
- transform: translateX(0px);
- }
- 20%,
- 40% {
- transform: translateX(15px);
- }
- 60%,
- 100% {
- transform: translateX(0px);
- }
- 80%,
- 90% {
- transform: translateX(-15px);
- }
- }
- @keyframes eys_white {
- 0% {
- transform: translateX(0px);
- }
- 20%,
- 40% {
- transform: translate3d(3px, 4px, 0px);
- }
- 60% {
- transform: translate(5px, 5px);
- }
- 80% {
- transform: translateX(0px);
- }
- 100% {
- transform: translateX(0px);
- }
- }
- @keyframes mouth_box {
- 40%,
- 43% {
- width: 45px;
- height: 25px;
- top: 175px;
- }
- 0%,
- 35%,
- 48%,
- 100% {
- width: 55px;
- height: 35px;
- top: 170px;
- transform: rotate(-35deg);
- }
- }
- @keyframes mouth_after {
- 40%,
- 43% {
- width: 60.5px;
- top: -19.3px;
- left: 1.5px;
- }
- 0%,
- 35%,
- 48%,
- 100% {
- width: 70px;
- top: -16px;
- left: 3px;
- transform: rotate(33deg);
- }
- }
- @keyframes left_hand {
- 0%,
- 50%,
- 100% {
- transform: rotate(40deg);
- }
- 30% {
- transform: rotate(37deg) translateX(1px);
- }
- }
- @keyframes right_foot {
- 0%,
- 50%,
- 100% {
- transform: rotate(0deg);
- }
- 30% {
- transform: rotate(-8deg);
- }
- }
- @keyframes left_foot {
- 0%,
- 50%,
- 100% {
- transform: rotate(0deg);
- }
- 80% {
- transform: rotate(8deg);
- }
- }
搞定了,没有做浏览器兼容,建议在chrome下浏览,以上就是本文的全部内容,希望对大家的学习有所帮助。
原文:http://www.cnblogs.com/zhangans/p/4883705.html
标签:
CSS3,小黄人
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
暂无“纯CSS3打造属于自己的“小黄人””评论...
《魔兽世界》大逃杀!60人新游玩模式《强袭风暴》3月21日上线
暴雪近日发布了《魔兽世界》10.2.6 更新内容,新游玩模式《强袭风暴》即将于3月21 日在亚服上线,届时玩家将前往阿拉希高地展开一场 60 人大逃杀对战。
艾泽拉斯的冒险者已经征服了艾泽拉斯的大地及遥远的彼岸。他们在对抗世界上最致命的敌人时展现出过人的手腕,并且成功阻止终结宇宙等级的威胁。当他们在为即将于《魔兽世界》资料片《地心之战》中来袭的萨拉塔斯势力做战斗准备时,他们还需要在熟悉的阿拉希高地面对一个全新的敌人──那就是彼此。在《巨龙崛起》10.2.6 更新的《强袭风暴》中,玩家将会进入一个全新的海盗主题大逃杀式限时活动,其中包含极高的风险和史诗级的奖励。
《强袭风暴》不是普通的战场,作为一个独立于主游戏之外的活动,玩家可以用大逃杀的风格来体验《魔兽世界》,不分职业、不分装备(除了你在赛局中捡到的),光是技巧和战略的强弱之分就能决定出谁才是能坚持到最后的赢家。本次活动将会开放单人和双人模式,玩家在加入海盗主题的预赛大厅区域前,可以从强袭风暴角色画面新增好友。游玩游戏将可以累计名望轨迹,《巨龙崛起》和《魔兽世界:巫妖王之怒 经典版》的玩家都可以获得奖励。
更新动态
2024年11月24日
2024年11月24日
- 凤飞飞《我们的主题曲》飞跃制作[正版原抓WAV+CUE]
- 刘嘉亮《亮情歌2》[WAV+CUE][1G]
- 红馆40·谭咏麟《歌者恋歌浓情30年演唱会》3CD[低速原抓WAV+CUE][1.8G]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[320K/MP3][193.25MB]
- 【轻音乐】曼托凡尼乐团《精选辑》2CD.1998[FLAC+CUE整轨]
- 邝美云《心中有爱》1989年香港DMIJP版1MTO东芝首版[WAV+CUE]
- 群星《情叹-发烧女声DSD》天籁女声发烧碟[WAV+CUE]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[FLAC/分轨][748.03MB]
- 理想混蛋《Origin Sessions》[320K/MP3][37.47MB]
- 公馆青少年《我其实一点都不酷》[320K/MP3][78.78MB]
- 群星《情叹-发烧男声DSD》最值得珍藏的完美男声[WAV+CUE]
- 群星《国韵飘香·贵妃醉酒HQCD黑胶王》2CD[WAV]
- 卫兰《DAUGHTER》【低速原抓WAV+CUE】
- 公馆青少年《我其实一点都不酷》[FLAC/分轨][398.22MB]
- ZWEI《迟暮的花 (Explicit)》[320K/MP3][57.16MB]