spoiler

spoiler keren

by Ahmad Najiullah

HTML

<div class="panelspoiler1258">
<div class="togglespoiler1258">
    <div class="openspoiler1258">
        <img src="https://dl.dropboxusercontent.com/u/52936372/file/campuran/plus6jcm3.png" alt="+">
        <a href="#">Buka Data SKPD</a>
    </div>
    <div class="closespoiler1258" style="display:none;">
        <img src="https://dl.dropboxusercontent.com/u/52936372/file/campuran/minuswfdlk.png" alt="-">
        <a href="#">Tutup Data SKPD</a>
    </div>
    
    <div class="contentspoiler1258" style="display:none;">Spoiler content</div>
</div>

CSS

.panelspoiler1258 {
    width: 95%;
    font-size: 15px;
}

.openspoiler1258, .closespoiler1258 {
    height: 32px;
    background: #d9d9d9;
    border: 1px solid #bdbdbd;
    -webkit-border-top-left-radius: 5px;
    -webkit-border-top-right-radius: 5px;
    -moz-border-radius-topleft: 5px;
    -moz-border-radius-topright: 5px;
    border-top-left-radius: 5px;
    border-top-right-radius: 5px;
}

.openspoiler1258 {
    -webkit-border-bottom-left-radius: 5px;
    -webkit-border-bottom-right-radius: 5px;
    -moz-border-radius-bottomleft: 5px;
    -moz-border-radius-bottomright: 5px;
    border-bottom-left-radius: 5px;
    border-bottom-right-radius: 5px;
		background: #d9d9d9;
		background: -moz-linear-gradient(top,  #d9d9d9 0%, #d1d1d1 100%);
		background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#d9d9d9), color-stop(100%,#d1d1d1));
		background: -webkit-linear-gradient(top,  #d9d9d9 0%,#d1d1d1 100%);
		background: -o-linear-gradient(top,  #d9d9d9 0%,#d1d1d1 100%);
		background: -ms-linear-gradient(top,  #d9d9d9 0%,#d1d1d1 100%);
		background: linear-gradient(to bottom,  #d9d9d9 0%,#d1d1d1 100%);
		filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#d9d9d9', endColorstr='#d1d1d1',GradientType=0 );

		-webkit-box-shadow: 0 0 0 1px #efefef inset;
    -moz-box-shadow: 0 0 0 1px #efefef inset;
    box-shadow: 0 0 0 1px #efefef inset;
}

.closespoiler1258 {
  	-webkit-box-shadow: 0 2px 3px 0 #888 inset;
    -moz-box-shadow: 0 2px 3px 0 #888 inset;
    box-shadow: 0 2px 3px 0px #888 inset;
}
  
.togglespoiler1258 {
    position: relative;
    height: 30px;
    line-height: 30px;   
}

.togglespoiler1258 img {
    position: absolute;
    top: 2px;
    left: 10px;
    cursor: pointer;
}

.togglespoiler1258 a {
    font-size: 16px;
    color: #000;
    text-decoration: none;
    display: block;
    padding-left: 45px;
}

.contentspoiler1258 {
    padding: 5px 10px;
    background: #d9d9d9;
    border-left: 1px solid #bdbdbd;
   ...

JavaScript

// Expand panelspoiler1258
    $(".openspoiler1258").click(function(){
        $(".contentspoiler1258").slideDown("fast", function() {
           $(".contentspoiler1258").animate({"height": "+=5px", }, "fast");
           $(".contentspoiler1258").animate({"height": "-=5px", }, "fast");
        });
        $(".openspoiler1258").hide();
        $(".closespoiler1258").show();
    });


    // Collapse panelspoiler1258
    $(".closespoiler1258").click(function(){
        $(".contentspoiler1258").animate({"height": "+=10px", }, "fast");
        $(".contentspoiler1258").slideUp("fast", function() {
           $(".contentspoiler1258").animate({"height": "-=10px", }, "fast");
           $(".closespoiler1258").hide();
           $(".openspoiler1258").show();
        });
    });