会变色的小鬼

会变色的小鬼

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>会变色的小鬼</title>
	</head>
	<body>
		 <div id="box">
		 	<div id="body">
		 		<div class="ears"></div>
		 		<div class="ears"></div>
		 		<div class="eyes left-eye"></div>
		 		<div class="eyes right-eye"></div>
		 		<div class="mouth"></div>
		 		<div id="foot">
			 		<div class="toenails"></div>
			 		<div class="toenails"></div>
			 		<div class="toenails"></div>
			 		<div class="toenails"></div>
		 	</div>
		 	</div>
		 </div>
	</body>
</html>
           *{
				margin: 0;
				padding: 0;
			}
			body{
				width: 100%;
				height:100vh;
				background: black;
			}
			#box{
				width: 200px;
				height: 300px;
				background: black;
				position: absolute;
				top: 100px;
				left:calc(50% - 100px);
				/*animation:设置动画效果*/
				animation: moving 5s linear infinite;
			}
			@keyframes moving{
				0%,50%,100%{
					transform: translateY(0px);
				}
				25%{
					transform: translateY(-15px);
				}
				75%{
					transform: translateY(15px);
				}
			}
			/*需要改变背景颜色的类*/
			#body,.ears,.mouth:before,.toenails{
				background:greenyellow;
			}
			#body{
				margin: 40px auto;
				margin-bottom: 0px;
				width: 80px;
				height: 90px;
				border-radius:50% 50% 0% 0% ;
				/*display: flex设置为弹性容器,所有子元素自动成为容器成员*/
				display: flex;
				animation: colors 5s linear infinite;
				/*filter: blur(1px);*/
			}
			/*设置滤镜效果
			 * filter: blur(1px);模糊度
			 * filter: hue-rotate(0deg);图像应用色相旋转
			 * 注意:先要给元素设置一个背景色,才能显示出滤镜hue-rotate()的效果;但是不能设置为black和white;
			 * */
			@keyframes colors{
				0%{
					filter: hue-rotate(0deg);
				}
				100%{
					filter: hue-rotate(360deg);
				}
			}
			.ears{
				width: 26px;
				height: 20px;
				border-radius: 50% 0% 0% 50%;
				position: absolute;
				top: 45px;
			}
			.ears:nth-child(1){
				left: -10px;
			}
			.ears:nth-child(2){
				transform: rotateY(180deg);
				left: 64px;
			}
			.eyes{
				width: 20px;
				height: 20px;
				border-radius: 50%;
				background:black;
				position: absolute;
				top: 30px;
				animation: zoomIn 3s linear infinite;
				z-index: 1000;
			}
			/*width:calc(100% - 10px);
			* 使用 calc() 函数计算 <div> 元素的宽度:
			* 需要注意的是,运算符前后都需要保留一个空格
			* 必须,一个数学表达式,结果将采用运算后的返回值。
			*  */
			.left-eye{
				left:calc(30% - 10px);
			}
			.right-eye{
				left:calc(70% - 10px);
			}
			.mouth{
				width: 20px;
				height: 30px;
				border-radius:50% 45%;
				background:black;
				position: absolute;
                top: 45px;
                left:calc(50% - 10px);
				animation: zoomIn 3s linear infinite;
			}
			.mouth:before{
				content: " ";
				display: block;
				width: 20px;
				height: 15px;
				position: absolute;
			}
			@keyframes zoomIn{
				0%,100%{
					transform: scaleY(1);
				}
				50%{
					transform: scaleY(0.5);
				}
			}
			#foot{
				width: 80px;
				height: 30px;
				position: absolute;
				top: 78px;
				display: flex;
			}
			#foot .toenails{
				width: 20px;
				height: 20px;
				border-radius:50% ;
				/*z-index:number; 属性指定一个元素的堆叠顺序,*/
				z-index: -100;
			}

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值