css3中的动画特效案例

引言
最近学完css3的知识,下面做了几个有趣案例,来帮助自己熟悉css3的知识。
一、升空的孔明灯

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>孔明灯</title>
		<style>
            *{
                padding: 0;
                margin: 0;
            }
            html{
                height: 100%;
                background-color: #000;
            }
            div{
                height: 100%;
                width: 100%;
                position: relative;
            }
            @keyframes run{
                0%{
                    top: 600px;
                }
                100%{
                    top: 100px;
                    width: 10px;
                    height: 10px;;
                }
            }

            div>img{
                width: 100px;
                height: 100px;
                display: inline-block;
                position: absolute;
                top: 800px;
                animation: run 10s infinite;
            }
            div>img:nth-child(1){
                left: 10px;
            }
            div>img:nth-child(2){
                left: 120px;
            }
            div>img:nth-child(3){
                left: 230px;
            }
            div>img:nth-child(4){
                left: 340px;
            }
            div>img:nth-child(5){
                left: 450px;
            }
            div>img:nth-child(6){
                left: 560px;
            }
            div>img:nth-child(7){
                left: 670px;
            }
            div>img:nth-child(8){
                left: 780px;
            }
		</style>
	</head>
	<body>
		<div>
            <img src="img/lable.jpg">
            <img src="img/lable.jpg">
            <img src="img/lable.jpg">
            <img src="img/lable.jpg">
            <img src="img/lable.jpg">
            <img src="img/lable.jpg">
            <img src="img/lable.jpg">
            <img src="img/lable.jpg">

        </div>
	</body>
</html>

在这里插入图片描述
二、旋转盒子

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        *{
			padding: 0;
			margin: 0;
		}
		html{
			height: 100%;
			background-image: linear-gradient(#29f9f0 0% , #000 80%);
		}
        @keyframes run{
			0%{
                transform: rotateX(0deg) rotateY(0deg) rotate(0deg);
			}
			100%{
                transform: rotateX(720deg) rotateY(360deg) rotate(360deg);
			}
		}
		.wapper{
			width: 300px;
			margin-top: 100px;
			perspective: 800px;
			margin: 50px auto;
		}
        .wapper .cube{
			width: 300px;
			height: 300px;
	        transform-style: preserve-3d;
	        position: relative;
	        transform: rotateX(-50deg) rotateY(-50deg) rotate(-50deg);
	        animation: run 10s infinite;
		}
		.wapper .cube span{
			transition: all 1s cubic-bezier(0.9,-0.2,1,1);
		}
		.cube>span{
			display: block;
			width: 90px;
			height: 90px;
			position: absolute;
			left: 50px;
			top: 50px;
			opacity: 0.8;
			background-color: rgba(0,100,120,1);

		}
	
		.cube span.num_front{
        	transform: translateZ(50px);
        	background-image: url(img/front.jpg);
        	background-size: cover;
        }
        .cube span.num_back{
        	transform: translateZ(-50px);
        	background-image: url(img/back.jpg);
        	background-size: cover;
        }
        .cube span.num_left{
        	transform: translateX(-50px) rotateY(90deg);
        	background-image: url(img/left.jpg);
        	background-size: cover;
        }
        .cube span.num_right{
        	transform: translateX(50px) rotateY(-90deg);
        	background-image: url(img/right.jpg);
        	background-size: cover;
        }
        .cube span.num_top{
        	transform: translateY(-50px) rotateX(90deg);
        	background-image: url(img/top.jpg);
        	background-size: cover;
        }
        .cube span.num_bottom{
        	transform: translateY(50px) rotateX(-90deg);
        	background-image: url(img/bottom.jpg);
        	background-size: cover;
        }
        
        .wapper .cube:hover .num_front{
        	
        	transform: translateZ(100px) scale(1.5);
        }
        .wapper .cube:hover .num_back{
        	
        	transform: translateZ(-100px) scale(1.5);
        }
        .wapper .cube:hover .num_left{
        	
        	transform: translateX(-100px) rotateY(90deg) scale(1.5);
        }
        .wapper .cube:hover .num_right{
        	
        	transform: translateX(100px) rotateY(-90deg) scale(1.5);
        }
        .wapper .cube:hover .num_top{
        	
        	transform: translateY(-100px) rotateX(90deg) scale(1.5);
        }
        .wapper .cube:hover .num_bottom{
        	
        	transform: translateY(100px) rotateX(-90deg) scale(1.5);
        }

    </style>
</head>
<body>
    <div class="wapper">
		<div class="cube">
			 <!-- 正面 -->
		     <span class="num_front">
		     	 
		     </span>
		     <!-- 反面 -->
		     <span class="num_back">
		     	
		     </span>
		     <!-- 左面 -->
		     <span class="num_left">
		       
		     </span>
		       <!-- 右面 -->
		     <span class="num_right">
		     	
		     </span>
		       <!-- 上面 -->
		     <span class="num_top">
		     	
		     </span>	
		       <!-- 下面 -->
		     <span class="num_bottom">
		     	
		     </span>		
		</div>
	</div>
</body>
</html>

在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值