2018-11-01

2018-11-01  本文已影响0人  一曲一人听

照片墙


画廊.gif

html代码

<!DOCTYPE html>
<html>
<head>
<title>照片墙</title>
<link rel="stylesheet" type="text/css" href="css.css">
<meta charset="utf-8">
</head>
<body onselectstart="return false;">
<div id="head">开始</div>
<div class="container" id="container">
<img src="img/01.jpg" id="img1">
<img src="img/02.jpg" id="img2">
<img src="img/03.jpg" id="img3">
<img src="img/04.jpg" id="img4">
<img src="img/05.jpg" id="img5">
<img src="img/06.jpg" id="img6">
<img src="img/07.jpg" id="img7">
<img src="img/08.jpg" id="img8">
</div>
<script type="text/javascript" src="js.js"></script>
</body>
</html>

css代码
*{
padding: 0;
margin: 0;
background: #eee;
}

head{

display: block;
height: 50px;
width: 70px;
border-style:outset;
line-height: 50px;
font-size: 20px;
margin: 0 auto;
text-align: center;
cursor: pointer;
border-color: #e0e0e0;

}
.container{
width: 1400px;
height: 900px;
margin: 60px auto;
position: relative;
}
.container img{
position: absolute;
width: 533px;
height: 300px;
text-align: center;
background-size: 100% 100%;
padding: 10px 10px 15px;
border: 1px solid #ddd;
}

img1{

top: 360px;
left: 500px;
transform: rotate(320deg);
z-index: 1;

}

img2{

top: 50px;
left: 400px;
transform: rotate(20deg);
z-index: 1;

}

img3{

top: 340px;
left: 700px;
transform: rotate(14deg);
z-index: 1;

}

img4{

top: 370px;
left: 50px;
transform: rotate(340deg);
z-index: 1;

}

img5{

top: 50px;
left: 900px;
transform: rotate(10deg);
z-index: 1;

}

img6{

top: 80px;
left: 20px;
transform: rotate(15deg);
z-index: 1;

}

img7{

top: 350px;
left: 900px;
transform: rotate(351deg);
z-index: 1;

}

img8{

top: 50px;
left: 200px;
transform: rotate(20deg);
z-index: 1;

}

js代码
function byId(id) {
return typeof(id) === "string"?document.getElementById(id):id; //判断id是否为字符串
}//封装一个代替getElementById()的方法

var btn = byId('head');
var container = byId('container');
var pits = byId('container').getElementsByTagName("img");
var len = pits.length;
var time = 2000;

var oldTop = new Array(8);
var oldLeft = new Array(8);
function stop(){

}
btn.onclick = function(){
oldLeft[0] = pits[0].offsetLeft;
oldTop[0] = pits[0].offsetTop;
oldLeft[1] = pits[1].offsetLeft;
oldTop[1] = pits[1].offsetTop;
oldLeft[2] = pits[2].offsetLeft;
oldTop[2] = pits[2].offsetTop;
oldLeft[3] = pits[3].offsetLeft;
oldTop[3] = pits[3].offsetTop;
oldLeft[4] = pits[4].offsetLeft;
oldTop[4] = pits[4].offsetTop;
oldLeft[5] = pits[5].offsetLeft;
oldTop[5] = pits[5].offsetTop;
oldLeft[6] = pits[6].offsetLeft;
oldTop[6] = pits[6].offsetTop;
oldLeft[7] = pits[7].offsetLeft;
oldTop[7] = pits[7].offsetTop;
function up0(){
pits[0].style.left = 450+'px';
pits[0].style.top = 200+'px';
pits[0].style.transition = 1+'s';
pits[0].style.transform = "rotate(0deg)";
pits[0].style.zIndex = 2;
pits[0].style.transform="scale(1.2)";
pits[0].style.boxShadow = "10px 10px 15px #ccc";

        }
        setTimeout(up0,0)

        function down0(){
            pits[0].style.left = oldLeft[0]+'px';
            pits[0].style.top = oldTop[0]+'px';
            pits[0].style.transition = 2+'s';
            pits[0].style.zIndex = 1;
            pits[0].style.transform="scale(1)";
            pits[0].style.transform = "rotate(320deg)";
            pits[0].style.boxShadow = " 0 0 0 #e0e0e0";
            
        }
        setTimeout(down0,1500);



        function up1(){
            pits[1].style.left = 450+'px';
            pits[1].style.top = 200+'px';
            pits[1].style.transition = 1+'s';
            pits[1].style.transform = "rotate(0deg)";
            pits[1].style.zIndex = 2;
            pits[1].style.transform="scale(1.2)";
            pits[1].style.boxShadow = "10px 10px 15px #ccc";
            

        }
        setTimeout(up1,2500)

        function down1(){
            pits[1].style.left = oldLeft[1]+'px';
            pits[1].style.top = oldTop[1]+'px';
            pits[1].style.transition = 2+'s';
            pits[1].style.zIndex = 1;
            pits[1].style.transform="scale(1)";
            pits[1].style.transform = "rotate(20deg)";
            pits[1].style.boxShadow = " 0 0 0 #e0e0e0";
            
        }
        setTimeout(down1,4000);

        function up2(){
            pits[2].style.left = 450+'px';
            pits[2].style.top = 200+'px';
            pits[2].style.transition = 1+'s';
            pits[2].style.transform = "rotate(0deg)";
            pits[2].style.zIndex = 2;
            pits[2].style.transform="scale(1.2)";
            pits[2].style.boxShadow = "10px 10px 15px #ccc";
            

        }
        setTimeout(up2,5000)

        function down2(){
            pits[2].style.left = oldLeft[2]+'px';
            pits[2].style.top = oldTop[2]+'px';
            pits[2].style.transition = 2+'s';
            pits[2].style.zIndex = 1;
            pits[2].style.transform="scale(1)";
            pits[2].style.transform = "rotate(14deg)";
            pits[2].style.boxShadow = " 0 0 0 #e0e0e0";
            
        }
        setTimeout(down2,6500);



        function up3(){
            pits[3].style.left = 450+'px';
            pits[3].style.top = 200+'px';
            pits[3].style.transition = 1+'s';
            pits[3].style.transform = "rotate(0deg)";
            pits[3].style.zIndex = 2;
            pits[3].style.transform="scale(1.2)";
            pits[3].style.boxShadow = "10px 10px 15px #ccc";
            

        }
        setTimeout(up3,7500)

        function down3(){
            pits[3].style.left = oldLeft[3]+'px';
            pits[3].style.top = oldTop[3]+'px';
            pits[3].style.transition = 2+'s';
            pits[3].style.zIndex = 1;
            pits[3].style.transform="scale(1)";
            pits[3].style.transform = "rotate(340deg)";
            pits[3].style.boxShadow = " 0 0 0 #e0e0e0";
            
        }
        setTimeout(down3,9000);




        function up4(){
            pits[4].style.left = 450+'px';
            pits[4].style.top = 200+'px';
            pits[4].style.transition = 1+'s';
            pits[4].style.transform = "rotate(0deg)";
            pits[4].style.zIndex = 2;
            pits[4].style.transform="scale(1.2)";
            pits[4].style.boxShadow = "10px 10px 15px #ccc";
            

        }
        setTimeout(up4,10000)

        function down4(){
            pits[4].style.left = oldLeft[4]+'px';
            pits[4].style.top = oldTop[4]+'px';
            pits[4].style.transition = 2+'s';
            pits[4].style.zIndex = 1;
            pits[4].style.transform="scale(1)";
            pits[4].style.transform = "rotate(10deg)";
            pits[4].style.boxShadow = " 0 0 0 #e0e0e0";
            
        }
        setTimeout(down4,11500);




        function up5(){
            pits[5].style.left = 450+'px';
            pits[5].style.top = 200+'px';
            pits[5].style.transition = 1+'s';
            pits[5].style.transform = "rotate(0deg)";
            pits[5].style.zIndex = 2;
            pits[5].style.transform="scale(1.2)";
            pits[5].style.boxShadow = "10px 10px 15px #ccc";
            

        }
        setTimeout(up5,12500)

        function down5(){
            pits[5].style.left = oldLeft[5]+'px';
            pits[5].style.top = oldTop[5]+'px';
            pits[5].style.transition = 2+'s';
            pits[5].style.zIndex = 1;
            pits[5].style.transform="scale(1)";
            pits[5].style.transform = "rotate(15deg)";
            pits[5].style.boxShadow = " 0 0 0 #e0e0e0";
            
        }
        setTimeout(down5,14000);




        function up6(){
            pits[6].style.left = 450+'px';
            pits[6].style.top = 200+'px';
            pits[6].style.transition = 1+'s';
            pits[6].style.transform = "rotate(0deg)";
            pits[6].style.zIndex = 2;
            pits[6].style.transform="scale(1.2)";
            pits[6].style.boxShadow = "10px 10px 15px #ccc";
            

        }
        setTimeout(up6,15000)

        function down6(){
            pits[6].style.left = oldLeft[6]+'px';
            pits[6].style.top = oldTop[6]+'px';
            pits[6].style.transition = 2+'s';
            pits[6].style.zIndex = 1;
            pits[6].style.transform="scale(1)";
            pits[6].style.transform = "rotate(351deg)";
            pits[6].style.boxShadow = " 0 0 0 #e0e0e0";
            
        }
        setTimeout(down6,16500);



        function up7(){
            pits[7].style.left = 450+'px';
            pits[7].style.top = 200+'px';
            pits[7].style.transition = 1+'s';
            pits[7].style.transform = "rotate(0deg)";
            pits[7].style.zIndex = 2;
            pits[7].style.transform="scale(1.2)";
            pits[7].style.boxShadow = "10px 10px 15px #ccc";
            

        }
        setTimeout(up7,17500)

        function down7(){
            pits[7].style.left = oldLeft[7]+'px';
            pits[7].style.top = oldTop[7]+'px';
            pits[7].style.transition = 2+'s';
            pits[7].style.zIndex = 1;
            pits[7].style.transform="scale(1)";
            pits[7].style.transform = "rotate(20deg)";
            pits[7].style.boxShadow = " 0 0 0 #e0e0e0";
            
        }
        setTimeout(down7,19000);

}

var img1 = byId("img1");
var img2 = byId("img2");
var img3 = byId("img3");
var img4 = byId("img4");
var img5 = byId("img5");
var img6 = byId("img6");
var img7 = byId("img7");
var img8 = byId("img8");

img1.onmouseover = function(){
img1.style.transition = 1+'s';
img1.style.transform = "rotate(0deg)";
img1.style.zIndex = 2;
img1.style.transform="scale(1.2)";
img1.style.boxShadow = "10px 10px 15px #ccc";
}
img1.onmouseout = function(){
img1.style.left = oldLeft[0]+'px';
img1.style.top = oldTop[0]+'px';
img1.style.transition = 1+'s';
img1.style.zIndex = 1;
img1.style.transform="scale(1)";
img1.style.transform = "rotate(320deg)";
img1.style.boxShadow = " 0 0 0 #e0e0e0";
}

img2.onmouseover = function(){
img2.style.transition = 1+'s';
img2.style.transform = "rotate(0deg)";
img2.style.zIndex = 2;
img2.style.transform="scale(1.2)";
img2.style.boxShadow = "10px 10px 15px #ccc";
}
img2.onmouseout = function(){
img2.style.left = oldLeft[1]+'px';
img2.style.top = oldTop[1]+'px';
img2.style.transition = 1+'s';
img2.style.zIndex = 1;
img2.style.transform="scale(1)";
img2.style.transform = "rotate(20deg)";
img2.style.boxShadow = " 0 0 0 #e0e0e0";
}

img3.onmouseover = function(){
img3.style.transition = 1+'s';
img3.style.transform = "rotate(0deg)";
img3.style.zIndex = 2;
img3.style.transform="scale(1.2)";
img3.style.boxShadow = "10px 10px 15px #ccc";
}
img3.onmouseout = function(){
img3.style.left = oldLeft[2]+'px';
img3.style.top = oldTop[2]+'px';
img3.style.transition = 1+'s';
img3.style.zIndex = 1;
img3.style.transform="scale(1)";
img3.style.transform = "rotate(14deg)";
img3.style.boxShadow = " 0 0 0 #e0e0e0";
}

img4.onmouseover = function(){
img4.style.transition = 1+'s';
img4.style.transform = "rotate(0deg)";
img4.style.zIndex = 2;
img4.style.transform="scale(1.2)";
img4.style.boxShadow = "10px 10px 15px #ccc";
}
img4.onmouseout = function(){
img4.style.left = oldLeft[3]+'px';
img4.style.top = oldTop[3]+'px';
img4.style.transition = 1+'s';
img4.style.zIndex = 1;
img4.style.transform="scale(1)";
img4.style.transform = "rotate(340deg)";
img4.style.boxShadow = " 0 0 0 #e0e0e0";
}

img5.onmouseover = function(){
img5.style.transition = 1+'s';
img5.style.transform = "rotate(0deg)";
img5.style.zIndex = 2;
img5.style.transform="scale(1.2)";
img5.style.boxShadow = "10px 10px 15px #ccc";
}
img5.onmouseout = function(){
img5.style.left = oldLeft[4]+'px';
img5.style.top = oldTop[4]+'px';
img5.style.transition = 1+'s';
img5.style.zIndex = 1;
img5.style.transform="scale(1)";
img5.style.transform = "rotate(10deg)";
img5.style.boxShadow = " 0 0 0 #e0e0e0";
}

img6.onmouseover = function(){
img6.style.transition = 1+'s';
img6.style.transform = "rotate(0deg)";
img6.style.zIndex = 2;
img6.style.transform="scale(1.2)";
img6.style.boxShadow = "10px 10px 15px #ccc";
}
img6.onmouseout = function(){
img6.style.left = oldLeft[5]+'px';
img6.style.top = oldTop[5]+'px';
img6.style.transition = 1+'s';
img6.style.zIndex = 1;
img6.style.transform="scale(1)";
img6.style.transform = "rotate(15deg)";
img6.style.boxShadow = " 0 0 0 #e0e0e0";
}

img7.onmouseover = function(){
img7.style.transition = 1+'s';
img7.style.transform = "rotate(0deg)";
img7.style.zIndex = 2;
img7.style.transform="scale(1.2)";
img7.style.boxShadow = "10px 10px 15px #ccc";
}
img7.onmouseout = function(){
img7.style.left = oldLeft[6]+'px';
img7.style.top = oldTop[6]+'px';
img7.style.transition = 1+'s';
img7.style.zIndex = 1;
img7.style.transform="scale(1)";
img7.style.transform = "rotate(351deg)";
img7.style.boxShadow = " 0 0 0 #e0e0e0";
}

img8.onmouseover = function(){
img8.style.transition = 1+'s';
img8.style.transform = "rotate(0deg)";
img8.style.zIndex = 2;
img8.style.transform="scale(1.2)";
img8.style.boxShadow = "10px 10px 15px #ccc";
}
img8.onmouseout = function(){
img8.style.left = oldLeft[7]+'px';
img8.style.top = oldTop[7]+'px';
img8.style.transition = 1+'s';
img8.style.zIndex = 1;
img8.style.transform="scale(1)";
img8.style.transform = "rotate(20deg)";
img8.style.boxShadow = " 0 0 0 #e0e0e0";
}

上一篇下一篇

猜你喜欢

热点阅读