Solved

Exapand/collapse Div's in html

Posted on 2012-04-12
6
189 Views
Last Modified: 2012-04-13
Hi,
  How can I implement expand/collpase panels using div's. I don't want to install any active-x controls. I want to implement something like shown in the image. Please help me how can I do it.

Thank you
expand-collpase.png
0
Comment
Question by:Sthokala
6 Comments
 
LVL 6

Expert Comment

by:bartvd
ID: 37839572
Hide the div:

div.style.display = "none";

Expand the div:

div.style.display = "block";
0
 
LVL 20

Expert Comment

by:BuggyCoder
ID: 37839746
0
 
LVL 20

Expert Comment

by:Proculopsis
ID: 37841261
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 7

Expert Comment

by:Atique Ansari
ID: 37841397
YOu can use jquery's slideToggle() function on div's click event.
0
 

Author Comment

by:Sthokala
ID: 37843034
Thank you for your answers. The code given is for horizontal panels..but I want the code to the two vertical panels. my question here is how can I insert an image in between two panels. please let me know.

Thank you
0
 
LVL 18

Accepted Solution

by:
nap0leon earned 500 total points
ID: 37843415
The panel layouts can be whatever you want.  In this example, they are named "left", "middle", and "right", but you can easily update the styles to make them "top", "middle", and "bottom" if you want...

All that is missing is that you place your image inside the div with id=middle (or set the image as middle's background) - whatever you prefer.

<script>
function toggleMiddle(){
	(document.getElementById('middle').style.display=='inline') ? document.getElementById('middle').style.display='none' : document.getElementById('middle').style.display='inline';
}
</script>
<style>
#left {border:1px solid black; height:300px; width:200px; float:left;}
#middle {border:1px solid black; height:300px; width:200px; float:left; display:none;}
#right {border:1px solid black; height:300px; width:200px; float:left;}
</style>
<div id="left">Left</div>
<div id="middle"></div>
<div id="right">Right</div>
<input type="button" onclick="toggleMiddle()">Toggle Middle DIV</input>

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Open Attachment from within List Field in SharePoint Online 1 28
How to avoid jquery conflicts in Wordpress ? 4 24
html5 auto send email 7 22
Message not shown 5 33
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now