473,396 Members | 1,966 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,396 software developers and data experts.

Forcing adjacent elements to have the same height

Is it possible to force adjacent block elements to have the same height,
without specifying that height?

In this page (http://pages.cpsc.ucalgary.ca/~degra...t/index3.html),
I have a bunch of (red-bordered) DIVs containing an image thumbnail and
a caption. These DIVs are floated to the left, and I used JavaScript to
center them (since there is no float: center and most browsers don't
support display: inline-block). I know the dimensions of the
thumbnails, so I can code the width into the stylesheet, but the
captions are script-generated, so I don't know the height of the
caption. Since I don't know the width of the browser window, I don't
know how many DIVs will fit on a row. I do, however, want all DIVs on
the same row to have the same height, which must be at least great
enough to enclose the longest caption in that row. It will be
sufficient if all of the image DIVs on the same page have the same height.

What I'm really trying to accomplish is to force these DIVs into rows
from the left edge to the right edge, with no gaps. If there's some
other way to accomplish this, please let me know.

Now, I known that I can do this with JavaScript or a table layout. Is
it possible with only CSS?

Thanks,
Rennie
Jul 24 '05 #1
3 3027
Rennie deGraaf <ca.ucalgary.cpsc@degraaf> wrote:
These DIVs are floated to the left, and I used JavaScript to
center them (since there is no float: center and most browsers don't
support display: inline-block).


IE 5.5+, Safari, iCab 1.3+ and Opera 7+ all support inline-block. Of the
modern browsers only Gecko based browsers do not support it.
http://www.spartanicus.utvinternet.i...h_captions.htm

--
Spartanicus
Jul 24 '05 #2
Spartanicus wrote:
Rennie deGraaf <ca.ucalgary.cpsc@degraaf> wrote:

These DIVs are floated to the left, and I used JavaScript to
center them (since there is no float: center and most browsers don't
support display: inline-block).

IE 5.5+, Safari, iCab 1.3+ and Opera 7+ all support inline-block. Of the
modern browsers only Gecko based browsers do not support it.
http://www.spartanicus.utvinternet.i...h_captions.htm


I tried implementing the same page using inline-block
(http://pages.cpsc.ucalgary.ca/~degra.../index4.html); in Konqueror,
the bottoms of the thumbnail DIVs are aligned correctly, but the tops
aren't aligned any more. Opera 8 gives the desired effect, but appears
to have some rendering bugs (it looks like the top of relatively
positioned elements is taken from the margin-top rather than the
object-top, or something). Of course, it doesn't work at all in
Firefox, and I haven't tested MSIE.

Mozilla's bug on support for inline-block has been open since 1999, so
I'm not optimistic on them supporting it any time soon. Since I use
Gecko-based browsers myself, I'm looking for another way to get similar
effects.

I took a look at your Mozilla workaround page, but it seems that the
layout breaks as soon as a comment wraps around onto a second line
(assuming that your limit the width of the caption cells). I tried
something similar myself
(http://pages.cpsc.ucalgary.ca/~degraaf/test/index2.html) and
encountered the same problem. Any idea on how to fix this?

Rennie
Jul 24 '05 #3
Rennie deGraaf <ca.ucalgary.cpsc@degraaf> wrote:
I took a look at your Mozilla workaround page, but it seems that the
layout breaks as soon as a comment wraps around onto a second line
(assuming that your limit the width of the caption cells). I tried
something similar myself
(http://pages.cpsc.ucalgary.ca/~degraaf/test/index2.html) and
encountered the same problem. Any idea on how to fix this?


The Mozilla work around is a method I do not support. The way to get
captions to wrap would be to specify a width for the <th>s, to get the
tops to align you'd then specify table{vertical-align:top}, the latter
triggers a bug in Gecko.

--
Spartanicus
Jul 24 '05 #4

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

Similar topics

2
by: Ney André de Mello Zunino | last post by:
Hello. The issue is quite known: you have a block-level container holding a set of floated elements and you need that the container's content height take the floated elements' dimensions into...
6
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...
12
by: Stanimir Stamenkov | last post by:
Here are two cases regarding inline-level elements' line-height, padding and background, which I doesn't understand: <div style="background: black; color: white; line-height: 1.5">...
3
by: NullBock | last post by:
Hey, so I'm trying to put two iframes on a page adjacent to each other. here's my code : <html> <head><style type="text/css"> body { margin: 0; }
1
by: SeaPlusPlus | last post by:
I have a problem, with html and css that verifies, that my menus will not exhibit hover when the cursor is exactly to the left of the image centered on my web page. The problem shows up in...
1
by: Sergey Ilinsky | last post by:
Well, while working on a rich ui with DHTML I discovered the following problem: Mozilla/Firefox seems to be wrong when rendered elements with sizes given in percents and that are placed into...
25
by: Dave | last post by:
Hello. In trying to get an anchor element to stylistically match an input or button element, I find that the button and input cannot be styled according to the 2.1 CSS spec. For example, I...
3
by: David Golightly | last post by:
I'm taking a stab at making CSS sparklines - see http://www.edwardtufte.com/bboard/q-and-a-fetch-msg?msg_id=0001OR&topic_id=1&topic= <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC...
5
by: Nathan Sokalski | last post by:
I'm not sure if this is the right place to ask this question, but I wasn't sure where else to go. I have a table made of the following tags: <table class="myclass"> <tbody> <tr><td>.</td></tr>...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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
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
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.