473,395 Members | 1,937 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

div heights

Hi

Pretty starightforward question I'm sure so hopefully someone can
enlighten me. If I have two divs next to each other how can I ensure
that both are the same height? E.g. if the right hand column contains
more text than the left I'd like the left hand column to be the same
height. So in the example below I'd like leftcontent1 to get its
height from rightcontent1. Ideas?

<style>
#page1 {
width: 600px;
float: left;
}

#leftcontent1 {
float: left;
width: 200px;
border: 1px solid #ccc;
}
#rightcontent1 {
float: left;
width: 200px;
border: 1px solid #ccc;
}
</style>

<div id="page1">0

<div id="leftcontent1">1</div>

<div id="rightcontent1">2<br><br><br><br><br></div>

</div>

MTIA

Jim

Sep 7 '05 #1
5 1513
Ok. After a bit more research I understand that this isn't as
straightforward as I expected. CSS sucks heh? ;)

The idea behind the design is that there is a background image on the
left hand column, so the more content you have on the right column the
more of the background image you see in the left hand column. I
understand that this isn't possible with CSS!

So what am I left with? Using tables it's a five minute job. But you
guys don't like tables anymore! ;)

Or use JS?

<script>
x = document.getElementById('leftnav');
y = document.getElementById('rightnav');
x.style.height = y.offsetHeight;
</script>

This will do what I want but I obviously don't want to use JS.

So what should I do? Any ideas?

Jim

Sep 8 '05 #2
ji***********@yahoo.co.uk wrote:
Ok. After a bit more research I understand that this isn't as
straightforward as I expected. CSS sucks heh? ;)


No, you can do this with CSS. Read chapter 17 in the CSS 2 (2.1)
specification. But this is not implemented in MS IE. IE sucks heh?
--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)
Sep 8 '05 #3
ji***********@yahoo.co.uk wrote:
Ok. After a bit more research I understand that this isn't as
straightforward as I expected. CSS sucks heh? ;)
No, IE does (easy peasy in proper browsers).
The idea behind the design is that there is a background image on the
left hand column, so the more content you have on the right column the
more of the background image you see in the left hand column. I
understand that this isn't possible with CSS!
Yawn: http://homepage.ntlworld.com/spartanicus/temp.htm
But you guys don't like tables anymore! ;)


You'll find few people arguing against tables used for tabular data,
you'll also find a more nuanced view on using tables for layout amongst
some of us.

--
Spartanicus
Sep 8 '05 #4
Many thanks.

Sep 8 '05 #5
ji***********@yahoo.co.uk wrote:
Ok. After a bit more research I understand that this isn't as
straightforward as I expected. CSS sucks heh? ;)

The idea behind the design is that there is a background image on the
left hand column, so the more content you have on the right column the
more of the background image you see in the left hand column. I
understand that this isn't possible with CSS!

So what am I left with? Using tables it's a five minute job. But you
guys don't like tables anymore! ;)

Or use JS?

<script>
x = document.getElementById('leftnav');
y = document.getElementById('rightnav');
x.style.height = y.offsetHeight;
</script>

This will do what I want but I obviously don't want to use JS.
No, it wont.

You are attempting to access the height property of the elements' style
object, but it doesn't have one - the height is determined (in this
case) by the browser's layout engine.

If the height had been set inline or using script, then yes, it'd work.
But it won't work if the height is set any other way (e.g. style rule
or inherited).

You need to use getComputedStyle for Mozilla and Opera and currentStyle
for IE, which adds the overhead of feature detection and having to wait
for the elements to be laid out before modifying them:

<URL:http://www.quirksmode.org/dom/getstyles.html>

So what should I do? Any ideas?


Using script for layout is nearly always the worst solution. Stick to
CSS or tables.

--
Rob
Sep 9 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Tyler Carver | last post by:
I am trying to create a table that 100% of the viewport with three rows. The top and bottom rows have a fixed height and the center row I want to take up the rest of the space. This work fine in...
1
by: Tyler Carver | last post by:
I am trying to create a table that is 100% of the viewport with three rows. The top and bottom rows have a fixed height and the center row I want to take up the rest of the space. This work fine...
3
by: cpt | last post by:
I read that if one uses "table-layout:fixed" then table rendering is speeded by setting row height. All my rows are 285 px high. 1) Is this true? 2) If true, how does one set row-height for the...
7
by: lauren quantrell | last post by:
A while back I got a requirement for the client to be able to adjust the relative heights of two subforms by click-dragging the mouse and I came up with a kludge solution using a border control...
1
by: Beringer | last post by:
Does anybody know a way to get the heights of the various lines of text in a RichTextBox? I'm not sure if "height" is the proper term. But what I'm getting at is that if you set the font size...
1
by: tshad | last post by:
Why are the text box heights of the input/file type textbox for uploading files a smaller height than a normal textbox? They have the exact same font and the same size font. But the heights...
2
by: sfeher | last post by:
Hi All, I am having trouble big times figuring out a way of forcing a DIV to be in synch with another DIV's height in a (mostly vertically) fluid layout in a web app context. The first one has...
7
by: hestres | last post by:
Hello, I'm having trouble figuring out how to make sure that all my DIVs in this layout are of the same height. Here's an example of a page where I'm having this problem: ...
5
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
I want to be able to increase or decrease row heights of a populated DataGridView from the keyboard. I set up a test program with menu items to increase and decrease, assigned shortkey keys...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.