JSFiddle - React, Tailwind, and code Playground
by Wolf Wortmann
March 30, 2014
HTML
<article>
<div class="klick left">▼</div>
<div class="left">
<span>gallerie.php</span>
<span>PHP JS Code</span>
</div>
<p>
Hier Steht some <br> Content <br> Und so Weiter, und so Weiter<br> Viel mehr kommt noch
</p>
</article>
CSS
span{
display: block;
margin-left: 20px;
}
.left{
float: left;
}
article{
max-height: 52px;
font-size: 14px;
color: #FFF;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
padding-top: 10px;
padding-bottom: 10px;
padding-right: 40px;
padding-left: 40px;
overflow: hidden;
background-color: rgba(28,28,28, 1);
-moz-transition: max-height 5s ease-in-out 0s;
-webkit-transition: max-height 5s ease-in-out 0s;
-o-transition: max-height 5s ease-in-out 0s;
transition: max-height 5s ease-in-out 0s;
}
p{
clear: both;
margin-top: 40px;
}
.klick{
transform: rotate(-90deg);
cursor:pointer;
}
JavaScript
window.onload=function(){
// Code toggle Box
function toggleArt(article,butn){
if (!article.style.maxHeight /*wenn noch nicht gesetzt*/
|| article.style.maxHeight == "52px")
{
article.style.maxHeight = "9999px";
/*article.style.transition= "height 1s";*/
butn.style.transform = "rotate(0deg)";
}
else{
article.style.maxHeight = "52px";
butn.style.transform = "rotate(-90deg)";
}
}
var article = document.getElementsByTagName("article");
var butn = document.getElementsByClassName("klick");
for (var i = 0; i < butn.length; i++){
butn[i].setAttribute("data-i", i);
butn[i].onclick = function(){
toggleArt(article[this.getAttribute("data-i")],
butn[this.getAttribute("data-i")]
);
}
}
}