关于css3动画---生动的小黄人

通过此案例,你会对css3的动画有一个深入且生动的了解。 调皮的小黄人了解一下。。。(虽然参照别人的案例,但是学到就是自己的哦?,简单的制作了一个gif,正常编写的效果很生动有趣) 

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8" />
	<title>yellow human</title>
	<style>
		.container{
			width:300px;
			margin:70px auto;
		}
		.yellow-boy{
			position:relative;
		}
		.body{
			position:absolute;
			width: 240px;
			height: 400px;
			border:5px solid #000;
			border-radius:115px;
			background:rgb(249,217,70);
			overflow:hidden;
		}
		.pants{
			height:100px;
			width:100%;
			position:absolute;
			bottom:0;
			border-top:6px solid #000;
			background:rgb(32,116,160);
		}
		.belt-left{
			width: 100px;
			height: 16px;
			background: rgb(32, 116, 160);
			position:absolute;
			top:-90px;
			left:-35px;
			z-index:1;
			border: 5px solid #000;
			transform:rotate(45deg);
		}
		.belt-left:after{
			content:'';
			width:8px;
			height:8px;
			background:#000;
			position:absolute;
			top: 4px;
			left: 88px;
			border-radius:50%;
		}
		.belt-right{
			width: 100px;
			height: 16px;
			background: rgb(32, 116, 160);
			position:absolute;
			top:-90px;
			left:165px;
			z-index:1;
			border: 5px solid #000;
			transform:rotate(-45deg);
		}
		.belt-right:after{
			content:'';
			width:8px;
			height:8px;
			background:#000;
			position:absolute;
			top:4px;
			left:4px;
			border-radius:50%;
		}
		.rectangle{
			width: 160px;
			height: 60px;
			border-radius:0 0 5px 5px;
			border:6px solid #000;
			border-bottom:none;
			background:rgb(32,116,160);
			position:absolute;
			bottom:100px;
			left:34px;
		}
		.pocket{
			width: 60px;
			height: 45px;
			position:absolute;
			bottom:65px;
			left:85px;
			border:5px solid #000;
			border-radius: 0 0 25px 25px;
		}
		.line-left{
			width: 35px;
			height: 35px;
			border-radius: 0 0 50px 0;
			border-right:5px solid #000;
			border-bottom:5px solid #000;
			position:absolute;
			top:5px;
		}
		.line-right{
			width: 35px;
			height: 35px;
			border-radius: 0 0 0 50px;
			border-left:5px solid #000;
			border-bottom:5px solid #000;
			position:absolute;
			top:5px;
			right:0;
		}
		.line-bottom{
			width: 35px;
			height: 45px;
			border-right:5px solid #000;
			position: absolute;
			bottom: 0;
			left: 82px;
		}
		.left-one{
			width: 55px;
			height: 55px;
			border-right: 8px solid #000;
			border-top-right-radius: 80px;
			position: absolute;
			top: -43px;
			left: 60px;
			z-index: -1;
			-webkit-transform: rotate(-20deg);
		    -webkit-animation:hair-left-one 2s ease-in-out infinite;
		}
		@keyframes hair-left-one{
			30%{
				position: absolute;
                top: -40px;
				left: 59px;
				rotate(-30deg);
			}
		}
		.left-two{
			width: 40px;
			height: 40px;
			border-right: 5px solid #000;
			border-top-right-radius: 50px;
			position: absolute;
			top: -27px;
			left: 70px;
			z-index: -1;
			-webkit-transform: rotate(-30deg);
		}
		.eyes-left,.eyes-right{
			width: 85px;
			height: 85px;
			border:6px solid #000;
			background:white;
			border-radius:50%;
			position:absolute;
			top:60px;
			left:27px;
			
		}
		.eyes-left:after {
			position: absolute;
			left: -30px;
			top: 37px;
			content: '';
			width: 28px;
			height: 18px;
			background: #000;
			-webkit-transform: skewX(20deg) rotate(7deg);
		}
		.eyes-right{
			left:124px;
		}
		.eyes-right:after {
			position: absolute;
			left: 88px;
			top: 37px;
			content: '';
			width: 28px;
			height: 18px;
			background: #000;
			-webkit-transform: skewX(-20deg) rotate(-7deg);
		}
		.left-eye-black{
			width: 40px;
			height: 40px;		
			border-radius:50%;
			background:#000;
			position:absolute;
			left: 22px;	
			top:24px;
			-webkit-animation:black-animation 5s ease-in-out infinite;
		}
		@keyframes black-animation{
			0%, 20%, 50%, 70%, 100%{
				-webkit-transform: translateX(0px);
			}
			30%, 40%{
				-webkit-transform: translateX(15px);
			}
			80%, 90%{
				-webkit-transform: translateX(-15px);
			}
		}
		.left-eye-white{
			width: 20px;
			height: 20px;
			background:#fff;
			border-radius:50%;
			position:absolute;
			top:7px;
			left:17px;
			-webkit-animation:white-animation 5s ease-in-out infinite;
		}
		@keyframes white-animation{
			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);
			}
			
		}
		.right-eye-black{
			width: 40px;
			height: 40px;		
			border-radius:50%;
			background:#000;
			position:absolute;
			left: 22px;	
			top:24px;
			-webkit-animation:black-animation 5s ease-in-out infinite;
		}
		.right-eye-white{
			width: 20px;
			height: 20px;
			background:#fff;
			border-radius:50%;
			position:absolute;
			top:7px;
			left:17px;
			-webkit-animation:white-animation 5s ease-in-out infinite;
		}
		.mouse{
			width: 55px;
			height: 35px;
			border:5px solid #000;
			border-bottom-left-radius: 35px;
			-webkit-transform:rotate(-35deg);
			position:absolute;
			top: 175px;
			left: 96px;
			-webkit-animation:mouse-animation 3s ease-in-out infinite;
		}
		@keyframes mouse-animation{
			50% {
                    top: 180px;
                    width: 42px;
                    height: 25px;
                }
		}
		.mouse:after{
			content:'';
			width: 76px;
			height: 35px;
			background:rgb(249,217,70);
			border-bottom:5px solid #000;
			position:absolute;
			top: -18px;
			left: -1px;
			-webkit-transform:rotate(35deg);
			-webkit-animation:mouse-shape 3s ease-in-out infinite;
		
		}
		@-webkit-keyframes mouse-shape {
            50% {
                top: -20px;
                left: 2px;
                width: 59px;
            }
        }
		.arms-left{
			width: 70px;
			height: 70px;
			border:5px solid #000;
			border-bottom-left-radius: 25px;
			background: rgb(249, 217, 70);
			-webkit-transform:rotate(45deg);
			position: absolute;
			top: 230px;
			left: -35px;
			z-index: -1;
			-webkit-animation:arms-left-animation 3s ease-in-out infinite;
		}
		.arms-left:after{
			content:'';
			width: 15px;
			height: 15px;
			border-left:5px solid #000;
			border-bottom:5px solid #000;
			border-bottom-left-radius:10px;
			background:#fff;
			position:absolute;
			top:28px;
			left:22px;
		}
		@keyframes arms-left-animation{
			30%{
				left: -28px;
				-webkit-transform:rotate(35deg); 
			}
		}
		.arms-right{
			width: 70px;
			height: 70px;
			border:5px solid #000;
			border-top-right-radius: 25px;
			background: rgb(249, 217, 70);
			-webkit-transform:rotate(45deg);
			position: absolute;
			top: 236px;
			left: 205px;
			z-index: -1;
			-webkit-animation:arms-right-animation 3s ease-in-out infinite;
		}
		.arms-right:after{
			content:'';
			width: 15px;
			height: 15px;
			border-right:5px solid #000;
			border-top:5px solid #000;
			border-top-right-radius:10px;
			background:#fff;
			position:absolute;
			top:22px;
			left:28px;
		}
		@keyframes arms-right-animation{
			30%{
				left: 198px;
				-webkit-transform:rotate(55deg); 
			}
		}
		.feet{
			position: absolute;
			top:400px;
		}
		.left-foot{
			position: absolute;
			top:-2px;
			left:90px;
			width:20px;
			height:50px;
			border:5px solid #000;
			border-bottom-right-radius: 10px;
			background: #000;
			z-index: -1;
			-webkit-animation: foot-left 0.8s ease-in-out infinite;
		}
		@-webkit-keyframes foot-left{
			0%, 50%, 100%{
				-webkit-transform: rotate(0deg);
			}
			30%{
				-webkit-transform: rotate(10deg);
			}
		}
		.left-foot:after{
			content: '';
			position: absolute;
			width: 50px;
			height:25px;
			left: -35px;
			top: 20px;
			border: 5px solid #000;
			background: #000;
			border-bottom-right-radius: 10px; 
			border-bottom-left-radius: 20px;
			border-top-left-radius: 25px;
		}
		.right-foot {
            position: absolute;
            top: -2px;
            left: 130px;
            width: 20px;
            height: 50px;
            border: 5px solid #000;
            border-bottom-left-radius: 10px;
            background: #000;
            z-index: -1;
            -webkit-animation: foot-right 0.8s ease-in-out infinite;
        }           
        .right-foot:after {
            content: '';
            position: absolute;
            left: -3px;
            top: 20px;
            width: 50px;
            height: 25px;
            border: 5px solid #000;
            background: #000;
            border-bottom-left-radius: 10px;
            border-bottom-right-radius: 20px;
            border-top-right-radius: 25px;
        }
		@-webkit-keyframes foot-right {
            0%, 50%, 100% {
                -webkit-transform: rotate(0deg);
            }
            80% {
                -webkit-transform: rotate(-10deg);
            }
        }
		.shadow{
			position: absolute;
            top: 460px;
            left: 25px;
            width: 200px;
            height: 2px;
			border-radius: 50%;
			background: rgba(0, 0, 0, 0.3);
			box-shadow: 0 0 2px 4px rgba(0, 0, 0, 0.3)
		}   
	</style>
</head>
<body>
	<div class="container">
		<div class="yellow-boy"><!--身体-->
			<div class="body">
			
				<div class="pants"><!--裤子-->
					<div class="belt"><!--背带-->
						<div class="belt-left"></div>
						<div class="belt-right"></div>
					</div>
					<div class="rectangle"></div><!--肚兜-->
					<div class="pocket"></div><!--小兜-->
					<div class="line-left"></div>
					<div class="line-right"></div>
					<div class="line-bottom"></div>
				</div>
			</div>
			
			<div class="hair"><!--头发-->
				<div class="left-one"></div>
				<div class="left-two"></div>
			</div>
			
			<div class="eyes"><!--眼睛-->
				<div class="eyes-left">
					<div class="left-eye-black">
						<div class="left-eye-white"></div>
					</div>
				</div>
				<div class="eyes-right">
					<div class="right-eye-black">
						<div class="right-eye-white"></div>
					</div>
				</div>
			</div>
			
			<div class="mouse"></div><!--嘴巴-->
			<div class="arms"><!--胳膊-->
				<div class="arms-left"></div>
				<div class="arms-right"></div>
			</div>
			
			<div class="feet"><!--双脚-->
                <div class="left-foot"></div>
                <div class="right-foot"></div>
            </div>
			
			<!--脚底阴影-->
            <div class="shadow"></div>
		</div> 
	</div>
</body>
</html>

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值