Solved

Script to match height of 2 divs

Posted on 2007-04-10
2
434 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

828 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