Solved

Script to match height of 2 divs

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

758 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

21 Experts available now in Live!

Get 1:1 Help Now