Collapsible Panel In Html/css
I'm putting together a website. I need help creating the following feature: I want the 'About' link to expand into a panel when clicked, and retract when the user presses 'hide' i
Solution 1:
This answer explains how it can be achieved in full: Pure CSS collapse/expand div
Here is a quick rundown:
<divclass="FAQ"><ahref="#hide1"class="hide"id="hide1">+</a><ahref="#show1"class="show"id="show1">-</a><divclass="question"> Question Question Question Question Question Question Question Question Question Question Question? </div><divclass="list"><p>Answer Answer Answer Answer Answer Answer Answer Answer Answer Answer Answer Answer Answer Answer Answer Answer Answer Answer </p></div></div>
CSS
/* source: http://www.ehow.com/how_12214447_make-collapsing-lists-java.html */.FAQ {
vertical-align: top;
height: auto;
}
.list {
display:none;
height:auto;
margin:0;
float: left;
}
.show {
display: none;
}
.hide:target + .show {
display: inline;
}
.hide:target {
display: none;
}
.hide:target ~ .list {
display:inline;
}
/*style the (+) and (-) */.hide, .show {
width: 30px;
height: 30px;
border-radius: 30px;
font-size: 20px;
color: #fff;
text-shadow: 01px0#666;
text-align: center;
text-decoration: none;
box-shadow: 1px1px2px#000;
background: #cccbbb;
opacity: .95;
margin-right: 0;
float: left;
margin-bottom: 25px;
}
.hide:hover, .show:hover {
color: #eee;
text-shadow: 001px#666;
text-decoration: none;
box-shadow: 004px#222 inset;
opacity: 1;
margin-bottom: 25px;
}
.listp {
height:auto;
margin:0;
}
.question {
float: left;
height: auto;
width: 90%;
line-height: 20px;
padding-left: 20px;
margin-bottom: 25px;
font-style: italic;
}
And the working jsFiddle:
http://jsfiddle.net/dmarvs/94ukA/4/
Again none of the above is my work just to clarify, but it just goes to show how easy it is to find it on Google!!
Solution 2:
You need litle javascript to trigger an event (show/hide div)
<ahref="#"> Home </a><aclass="right"href="javascript:toggle_messege('inline')"id='href_about'> About </a><br /><aclass="right hide"href="javascript:toggle_messege('none')"id='hreh_close'> (Close)</a><divid='div_messege'class='hide'>Hidden messege to show, Hidden messege to show Hidden messege to show Hidden messege to show</div><p>Test Test TestTestTestTestTestTestTest</p><p>Test Test TestTestTestTestTestTestTest</p><p>Test Test TestTestTestTestTestTestTest</p><p>Test Test TestTestTestTestTestTestTest</p><p>Test Test TestTestTestTestTestTestTest</p>
CSS
.right {
float:right;
}
.hide {
display:none
}
javascript
functiontoggle_messege(type) {
document.getElementById("div_messege").style.display = type;
document.getElementById("hreh_close").style.display = type;
}
check this for running example http://codepen.io/faishal/pen/IHEyw
Post a Comment for "Collapsible Panel In Html/css"