码迷,mamicode.com
首页 > 其他好文 > 详细

手风琴特效

时间:2016-11-15 07:54:24      阅读:221      评论:0      收藏:0      [点我收藏+]

标签:title   tle   body   ges   pre   else   onclick   element   技术   

一种是鼠标悬浮,一种是点击。

body里

技术分享
<div style=" width:700px; height:300px;  overflow:hidden;position:relative;">
    <div id="d1" style="width:500px; height:300px; position:absolute; float:left; transition:0.7s;" onMouseOver="bian(1)"></div>
    <div id="d2" style="width:500px; height:300px; position:absolute; float:left; left:50px; transition:0.7s;" onMouseOver="bian(2)"></div>
    <div id="d3" style="width:500px; height:300px; position:absolute; float:left; left:100px; transition:0.7s;" onMouseOver="bian(3)"></div>
    <div id="d4" style="width:500px; height:300px; position:absolute; float:left; left:150px; transition:0.7s;" onMouseOver="bian(4)"></div>
    <div id="d5" style="width:500px; height:300px; position:absolute; float:left; left:200px; transition:0.7s;" onMouseOver="bian(5)"></div>
</div>
<br>
<div style=" width:700px; height:300px;  overflow:hidden;position:relative;">
    <div id="dd1" style="width:500px; height:300px; position:absolute; float:left; transition:0.7s;" onClick="biann(1)"></div>
    <div id="dd2" style="width:500px; height:300px; position:absolute; float:left; left:50px; transition:0.7s;" onClick="biann(2)"></div>
    <div id="dd3" style="width:500px; height:300px; position:absolute; float:left; left:100px; transition:0.7s;" onClick="biann(3)"></div>
    <div id="dd4" style="width:500px; height:300px; position:absolute; float:left; left:150px; transition:0.7s;" onClick="biann(4)"></div>
    <div id="dd5" style="width:500px; height:300px; position:absolute; float:left; left:200px; transition:0.7s;" onClick="biann(5)"></div>
</div><br>
技术分享

js里

技术分享
<script language="javascript1.1">
function bian(n)
{
    if(n==1){
        document.getElementById("d1").style.left="";
        document.getElementById("d2").style.left="500px";
        document.getElementById("d3").style.left="550px";
        document.getElementById("d4").style.left="600px";
        document.getElementById("d5").style.left="650px";
    }
    else if(n==2){
        document.getElementById("d1").style.left="";
        document.getElementById("d2").style.left="50px";
        document.getElementById("d3").style.left="550px";
        document.getElementById("d4").style.left="600px";
        document.getElementById("d5").style.left="650px";
        }
    else if(n==3){
        document.getElementById("d1").style.left="";
        document.getElementById("d2").style.left="50px";
        document.getElementById("d3").style.left="100px";
        document.getElementById("d4").style.left="600px";
        document.getElementById("d5").style.left="650px";
        }
    else if(n==4){
        document.getElementById("d1").style.left="";
        document.getElementById("d2").style.left="50px";
        document.getElementById("d3").style.left="100px";
        document.getElementById("d4").style.left="150px";
        document.getElementById("d5").style.left="650px";
        }
    else if(n==5){
        document.getElementById("d1").style.left="";
        document.getElementById("d2").style.left="50px";
        document.getElementById("d3").style.left="100px";
        document.getElementById("d4").style.left="150px";
        document.getElementById("d5").style.left="200px";
        }
}
function biann(n)
{
    if(n==1){
        document.getElementById("dd1").style.left="";
        document.getElementById("dd2").style.left="500px";
        document.getElementById("dd3").style.left="550px";
        document.getElementById("dd4").style.left="600px";
        document.getElementById("dd5").style.left="650px";
    }
    else if(n==2){
        document.getElementById("dd1").style.left="";
        document.getElementById("dd2").style.left="50px";
        document.getElementById("dd3").style.left="550px";
        document.getElementById("dd4").style.left="600px";
        document.getElementById("dd5").style.left="650px";
        }
    else if(n==3){
        document.getElementById("dd1").style.left="";
        document.getElementById("dd2").style.left="50px";
        document.getElementById("dd3").style.left="100px";
        document.getElementById("dd4").style.left="600px";
        document.getElementById("dd5").style.left="650px";
        }
    else if(n==4){
        document.getElementById("dd1").style.left="";
        document.getElementById("dd2").style.left="50px";
        document.getElementById("dd3").style.left="100px";
        document.getElementById("dd4").style.left="150px";
        document.getElementById("dd5").style.left="650px";
        }
    else if(n==5){
        document.getElementById("dd1").style.left="";
        document.getElementById("dd2").style.left="50px";
        document.getElementById("dd3").style.left="100px";
        document.getElementById("dd4").style.left="150px";
        document.getElementById("dd5").style.left="200px";
        }
}
</script>

手风琴特效

标签:title   tle   body   ges   pre   else   onclick   element   技术   

原文地址:http://www.cnblogs.com/baimangguo/p/6064172.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!