Solved

Script to match height of 2 divs

Posted on 2007-04-10
2
430 Views
Last Modified: 2012-05-05
I am looking for a piece of script that works onload to check the height of div A, and then sets the height of div B to match
0
Comment
Question by:jarrodprice
2 Comments
 
LVL 5

Expert Comment

by:PhilHow
ID: 18886761
Exact code is posted here:

http://snippets.dzone.com/posts/show/3791

I think is written by Coboldinosaur was an expert here at EE once.
0
 
LVL 6

Accepted Solution

by:
ije earned 500 total points
ID: 18887272
<html>
<head>
<title>IJE Div Leveler</title>
<script type="text/javascript">
window.onload = function(){
  document.getElementById('divB').style.height = document.getElementById('divA').offsetHeight;
}
</script>
</head>
<body>
  <div id="divA" style="height:400px; background-color:#D50000">
    <p>This is div 1</p>
  </div>
  <div id="divB" style="background-color:#8ECEFB">
    <p>This is div 2</p>
  </div>
</body>
</html>
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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

914 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

20 Experts available now in Live!

Get 1:1 Help Now