CSS 2D動畫效果

示例1(盾牌動畫):

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>盾牌動畫</title>
    <link rel="shortcut icon" href="bkq.ico"  type="image/x-icon"/>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        body {
            background-color: #ff3040;
        }
        div {
            width: 440px;
            margin: 100px auto;
        }
        div img {
            transition: all 1s;
        }
        div img:nth-child(1) {
            transform: translate(200px,-100px) rotate(60deg);
        }
        div img:nth-child(2) {
            transform: translate(-300px,-150px) rotate(90deg);
        }
        div img:nth-child(3) {
              transform: translate(-100px,180px) rotate(-100deg);
        }
        div img:nth-child(4) {
            transform: translate(-80px,80px) rotate(125deg);
        }
        div img:nth-child(5) {
            transform: translate(200px,-100px) rotate(150deg);
        }
        div img:nth-child(6) {
            transform: translate(180px,180px) rotate(180deg);
        }
        div img:nth-child(7) {
            transform: translate(120px,120px) rotate(120deg);
        }
        div img:nth-child(8) {
            transform: translate(130px,140px) rotate(150deg);
        }
        div img:nth-child(9) {
            transform: translate(500px,-305px) rotate(390deg);
        }
        div:hover img {
            transform: none;
        }
    </style>
</head>
<body>
<div>
    <img src="img/shield_1_01.png" alt=""/>
    <img src="img/shield_1_02.png" alt=""/>
    <img src="img/shield_1_03.png" alt=""/>
    <img src="img/shield_1_04.png" alt=""/>
    <img src="img/shield_1_05.png" alt=""/>
    <img src="img/shield_1_06.png" alt=""/>
    <img src="img/shield_1_07.png" alt=""/>
    <img src="img/shield_1_08.png" alt=""/>
    <img src="img/shield_1_09.png" alt=""/>
</div>
</body>
</html>

 

示例2(楚喬傳旋轉動畫):

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>楚喬傳</title>
    <style>
     div {
         width: 250px;
         height: 170px;
         /*border: 1px solid pink;*/
         margin: 200px auto;
         position: relative;
     }
        div img {
            width: 100%;
            height: 100%;
            position: absolute;
            top: 0;
            left: 0;
            transition: all 0.6s;
            transform-origin: top right;

        }
     /*鼠標經過div 第一張圖片旋轉*/
     div:hover img:nth-child(1){
         transform: rotate(60deg);
     }
     div:hover img:nth-child(2){
         transform: rotate(120deg);
     }
     div:hover img:nth-child(3){
         transform: rotate(180deg);
     }
     div:hover img:nth-child(4){
         transform: rotate(240deg);
     }
     div:hover img:nth-child(5){
         transform: rotate(300deg);
     }
     div:hover img:nth-child(6){
         transform: rotate(360deg);
     }
    </style>
</head>
<body>
<div>

    <img src="img/6.jpg" alt=""/>
    <img src="img/5.jpg" alt=""/>
    <img src="img/4.jpg" alt=""/>
    <img src="img/3.jpg" alt=""/>
    <img src="img/2.jpg" alt=""/>
    <img src="img/1.jpg" alt=""/>
</div>
</body>
</html>

 

示例3(音樂盒子):

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>音樂盒子</title>
	<style type="text/css">
	body{
		background: pink;
	}
	.box{
		width: 300px;
		height: 300px;
		margin:100px auto;
		position: relative;
	}
	.top,.bottom{
		position: absolute;
		top:0;
		left:0;
		width: 100%;
		height: 100%;
		overflow: hidden;
		border-radius: 50%;
		transform-origin:bottom; /*設置旋轉元素的基點位置*/
		transition: all 0.5s ease 0s;
	}
	.box:hover .top{
		transform:rotateX(180deg);
	}
	</style>
</head>
<body>
	<div class="box">
		
		<div class="bottom"><img src="img/musicb.jpg" alt=""></div>
		<div class="top"><img src="img/musict.jpg" alt=""></div>
	</div>
</body>
</html>

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章