$(function() {
// when to clicking on any item show the info about him and hide other info elemnet
$(".item").on("click", function() {
$(this).toggleClass("active");
if($(this).hasClass('active')){
$(this)
.next().show().animate({width: "12%"});
}
else{
$(".info").hide()
.animate({width: "0"});
}
});
});
*{
box-sizing: border-box;
}
body{
background: white;
color: #D74F33;
}
section {
width: 1900px;
margin: 10px auto;
position: fixed;
left:-8px;
}
.item{
width:9%;
height: 40px;
float: left;
border-right: 3px solid #D74F33;
font: 20px monospace;
padding: 10px;
cursor: pointer;
background-color: #333;
transform: skew(-20deg);
-webkit-transform: skew(-20deg);
-moz-transform: skew(-20deg);
text-align: center;
-webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
-moz-box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
}
.info{
float: left;
width:0%;
height: 40px;
background: #4B3E4D;
display: none;
font: 20px monospace;
padding: 10px;
background-color: gr;
transform: skew(-20deg);
-webkit-transform: skew(-20deg);
-moz-transform: skew(-20deg);
text-align: center;
-webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
-moz-box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<html >
<head>
<meta charset="UTF-8">
<title>Horizontal Accordion </title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<section>
<div class="item"> about ►</div>
<div class="info">lab | research</div>
<div class="item"> people ►</div>
<div class="info">current | alumni</div>
</section>
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src="js/index.js"></script>
</body>
</html>
Возможный дубликат [выпадающее меню с по щелчку тумблера] (http://stackoverflow.com/questions/17388122/drop-down-menu-with-on -click-toggle) – wscourge
Вы пытались использовать 'slideToggle'? –