473,796 Members | 2,464 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3062
Rennie deGraaf <ca.ucalgary.cp sc@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.cp sc@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.cp sc@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
2875
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 consideration. E.g.: <div class="images"> <div class="image"><img src="example1.png" width="160" height="120" alt=""></div> <div class="image"><img src="example2.png" width="160" height="120"
6
7734
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'.
12
6742
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"> <span>Abc</span> <span style="background: white; color: black; line-height: 3">Abc</span> <span>Abc</span> </div>
3
6636
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
1805
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 Netscape, Firefox, and Opera but NOT in IE... arrrggghhh! ! ! ! I have a second problem with this impementation of HTML 4 strict. I'd like to know which elements in xbasic.css should I hide (using @import) from Netscape 4 so the page will degrade...
1
2130
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 another elements with percentage sizes, if the content overflows them (of course, overflow is set to the value of "scroll") To check the written above please use the given below code <table style="" height="50%" width="100%">
25
2480
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 expected this ruleset: ..but { display: block; background-color: red; font-size: 14px; text-decoration: none; line-height: 16px; width: auto; height: 16px; padding: 0; margin: 0;
3
3236
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 "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" > <head> <title>Sparklines</title> <style type="text/css">
5
1762
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> <tr><td>.</td></tr> <tr><td>.</td></tr> </tbody> </table>
0
9528
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
10456
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10230
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
9052
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
7548
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
5575
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4118
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
3731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2926
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.