473,659 Members | 2,663 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Table cells of equal height using divs

Hello!

I want a table-like layout (2 x 2 cells), but as it's not tabular data I
want to do it with divs and CSS. Here's what I have come up with so far
(using an HTML 4.01 Strict doctype):

div.table {position:relat ive; width:100%;}
div.row {clear:both; padding-top:2%;}
div.left {float:left;}
div.right {float:right;}
div.left, div.right {width:48%; background-color:yellow; border:1px solid
black;}
div.clear {clear: both;}

<div class="table">
<div class="row">
<div class="left">Ce ll 1<br>Second line</div>
<div class="right">C ell 2</div>
</div>
<div class="row">
<div class="left">Ce ll 3</div>
<div class="right">C ell 4</div>
</div>
<div class="clear"></div>
</div>

Basically, it works (tested on IE5, IE6, Mozilla and Opera), but there are
two things that I don'T like:

1) The horizontal and vertical gaps are in % and change with the browser
window's size. I would like to have them both equal and be something like
"5px".
2) I would like all cells in a row to be as high as the highest cell of the
respective row (the shorter cells increasing their "bottom padding" as
necessary).
3) I don't want to specify fixed widths or heights, but keep the layout
fluid. Also, this layout should work with older browsers like IE5.x.

Is there a way to achieve this?

Greetings,
Thomas


Jul 20 '05 #1
0 3122

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

Similar topics

61
24464
by: Toby Austin | last post by:
I'm trying to replace <table>s with <div>s as much as possible. However, I can't figure out how to do the following… <table> <tr> <td valign="top" width="100%">some data that will 'stretch'</td> <td valign="top" width="300">some data that won't 'stetch'</td> </tr> </table>
6
7714
by: Finn Newick | last post by:
By defining a style as follows: @media aural, handheld {td.layout {display:block;}} I'm hoping to linearise layout tables when viewed by screenreaders and handheld devices (it is also be in some selectable user preferences). This works as intended in Netscape 7 - all the cells stack vertically above each other nicely, but not in Internet Explorer 6 where the only display property that td will respond to seems to be 'none'.
0
2362
by: Linda Antonsson | last post by:
Hi, I am trying to put together a CSS-based layout consisting of a header, a sidebar and a main content area. Page: http://www.westeros.org/ASoWS/ CSS: http://www.westeros.org/ASoWS/ASoWS-All.css (the relevant IDs are towards the bottom) JS: http://www.westeros.org/ASoWS/SetHeight.js
1
3961
by: marek | last post by:
if table body has specified height set, which would be taller than the summa of the specified heighted cells, should the cells heights be adjusted to be more taller, so the summa height will equal the height specified in table body? -- Marek Mänd Estonia, Tallinn
4
26206
by: N. Demos | last post by:
The following code renders as intended in IE (A TABLE, with cells of fixed width and height, inside of a DIV with fixed width and height and overflow set to hidden.) In Firefox, the table cells assume a narrower with than specified. If I comment out the width for the DIV, then the cells render with the correct width and height. Why is this happening? Thanks. Regards, N. Demos
117
18497
by: phil-news-nospam | last post by:
Is there really any advantage to using DIV elements with float style properies, vs. the old method of TABLE and TR and TD? I'm finding that by using DIV, it still involves the same number of elements in the HTML to get everything just right. When you consider the class attribute on the DIV elements, there's not much size savings anymore for using DIV. There are other disadvantages to not using TABLE/TR/TD, such as the lack of ability...
3
2315
by: markszlazak | last post by:
Firefix works fine but I'm having a problem inserting a DIV into a HTML table cell dynamically with IE 6. The following code has a two cell table with one DIV hard-coded into the first (top) cell and a second DIV put in via Javascript. The second DIV shows up like the first in Firefox. However, in IE 6, only the text within the second DIV shows but the DIV's style and positioning are lost. What is the problem? <html> <head>
2
3811
by: Jukka K. Korpela | last post by:
Sub titulo "Re: DIV borders different in IE7 when in td" scripsit Ben C: This seems to be the heart of the matter, and I'm trying to get a real discussion started, by moving the discussion to the right group (c.i.w.a.stylesheets) and changing the Subject line. It seems to me that IE 7, specifically in "standards mode" (!), misbehaves when a table cell has a declared width but the actual width
6
2698
by: Roderik | last post by:
I was wondering if there is a good way to avoid a table but achieve the following similar behaviour: Two divs of equal height and undefined width next to each other with a total width of 100%. The width of the first (left) div should be the width needed to contain its content on one line. The other div should take the rest of the available width. Which content that comes into the first div is not know in advance. This can be achieved...
0
8427
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8330
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8746
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8626
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7355
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6178
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2749
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.