JAVASCRIPT+CSS3 Simple Accordion effect

Source: Internet
Author: User
Tags tagname

<! DOCTYPE html>
<meta charset= "Utf-8" >
&LT;TITLE&GT;JAVASCRIPT+CSS3 Simple Accordion Effect </title>
<style>
#imageMenu {Width:500px;height:200px;overflow:hidden;}
#imageMenu ul *{transition:all linear 0.2s;}
#imageMenu ul{width:800px;height:200px;padding:0; margin:0; List-style:none}
#imageMenu Li{float:left;}
#imageMenu ul Li A{width:73px;height:110px;overflow:hidden;}
#imageMenu ul big a {width:200px;}
#imageMenu Li a{width:98px;height:200px;display:block;text-indent:9999px;border-right:2px solid #fff; cursor: Pointer;overflow:hidden;}
#imageMenu. Landscapes A{background:url (http://img.funshion.com/pictures/media/list/109/251/109251_200_110.jpg? 1405409131) No-repeat;}
#imageMenu. People A{background:url (http://img.funshion.com/pictures/media/list/109/562/109562_200_110.jpg? 1386039195) No-repeat;}
#imageMenu. Nature A{background:url (http://img.funshion.com/pictures/media/list/101/158/101158_200_110.jpg? 1405677722) No-repeat;}
#imageMenu. Urban A{background:url (http://img.funshion.com/pictures/media/list/103/960/103960_200_110.jpg? 1395209765) No-repeat;}
#imageMenu. Abstract A{background:url (http://img.funshion.com/pictures/media/list/106/935/106935_200_280.jpg? 1405186860) No-repeat;}
</style>
<body>
<div id= "ImageMenu" >
<ul>
<li class= "Landscapes" >
<a href= "#link1" >Landscapes</a>
</li>
<li class= "People big" >
<a href= "#link1" >People</a>
</li>
<li class= "Nature" >
<a href= "#link1" >Nature</a>
</li>
<li class= "Urban" >
<a href= "#link1" >Urban</a>
</li>
<li class= "abstract" >
<a href= "#link1" >Abstract</a>
</li>
</ul>
</div>
<script type= "Text/javascript" >
function bind (Ele, Evtype, callback) {
if (typeof Ele.addeventlistener = = = ' function ') {
Ele.addeventlistener (Evtype, callback, false);
}else if (typeof ele.attechevent = = = ' function ') {
Ele.attechevent (' On ' +evtype, callback);
}
}

function Mouseoverhander (EV, lists) {
var imagemenu = document.getElementById (' ImageMenu ');
var lists = imagemenu.getelementsbytagname (' li ');
Lists = Lists | | [];
var target = Ev.target | | Ev.srcelement;

for (var i = 0; i < lists.length; i++) {
Simple regular expressions have ' big ' (here match space and big) This class is replaced by "
Lists[i].classname = Lists[i].classname.replace (/? big/g, ");
}

If the current element is not Li looking for his parent node, when bubbling to the body, exit
while (Target.tagName.toLowerCase ()! = ' Li ' && target.tagName.toLowerCase ()! = ' body ') {
target = Target.parentnode;
}

Target.classname + = ' big ';
}

Window.onload = function () {
var imagemenu = document.getElementById (' ImageMenu ');
var lists = imagemenu.getelementsbytagname (' li ');

for (var i = 0, L = lists.length; i < L; i++) {
Bind (Lists[i], ' mouseover ', function (e) {
Mouseoverhander (E, lists);
});
}
}
</script>
</body>

JAVASCRIPT+CSS3 Simple Accordion effect

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.