tags:

views:

61

answers:

2

Hello.
I am having trouble in coming up with a good idea on how to do this layout. Click for the image.

So basically there are 2 columns. Left and right. Both columns are separated into the upper part and lower part (upper part is the same height in both columns). The upper part has a semi-opaque background image, through which one can see the background image (which is very variable, so taking screenshots isn't an option). The lower part is plain colored.
The left column in the upper part (call it Area 1) contains elements, the height of which will dictate the height of the whole semi-opaque upper part of both columns. More text in Area 1 means that the semi-opaque part will become higher, to fit all the text.
The left column in the lower (Area 2) part contains elements which will enlarge the white background container if they won't fit.
The right part contains one single box (Area 3), from top to bottom. Its height doesn't influence the upper (semi-opaque) part at all, but it does influence, along with Area 2, the height of the white container below, which will have to become high enough to fit both of them.

So, how do I make the upper (semi-opaque) part stop right after Area 1? And how do I make Area 3 expand down without influencing the upper part, but influencing the lower part's height? I know how to do this using JavaScript, but I need this working in CSS, at least for the latest browsers (I can place some JS for older browsers like IE7).

Thank you.

P.S. Sorry for the not-so-clear title. I found it difficult to express this question in this volume of text, not to speak of a short title to describe it.

A: 

I made similar layouts in 3 ways. 1 - divs + css - this is hell, you'll waste a lot of time for it. 2 - Using JS, but you want to avoid it. And 3 - using a table. If Area 3 is to have height of 1 + 2, the table is reasonable, quick and easy. To use transparency use either 24-bit PNGs, or rgba color, which is possible to use in IE (all versions) as background using this technique. There is a way to add a new CSS property for IE (-ms-background-color) with rgba support if you don't mind using JS/jQuery.

Harry
how do I expand the semi-opaque background to the second column in a Table layout? It does look like a table, yes, a 2x2 table, but the contents from the second column are placed in one row, but the background is in 2 rows.
Alexander
I've checked this out, there's no way of doing this without JS. The way to expand the background is to use position absolute, and then play with z-index properties of layers, but when using position: absolute you cannot use % dimmensions any more, you have to use pixels. What's more, absolute positioned layers don't affect layout in any way (don't take up any layout space), so no other box will expand to fit them. Use jQuery, you'll do it in no time.
Harry
@Harry, check out the solution, with no JS, and quite a simple one too. Has troubles on IE7, but IE7 wasn't my target :)
Alexander
COOL! I forgot to reload the page...
Harry
+3  A: 

So, how do I make the upper (semi-opaque) part stop right after Area 1? And how do I make Area 3 expand down without influencing the upper part, but influencing the lower part's height?

edit
My bad, absolutes won't work. But you can actually do it easier with floats. Fixed example.

Nikita Rybak
it doesn't expand the lower (plain colored) container though. If Area 2 will have a lower bound which is higher than that of Area 3, Area 3 will end up on the site background, outside any container. I am trying to avoid that.
Alexander
Won't work. The absolute positioned div will break out of the main container and there's no way (using *pure* CSS) to force the main container to expand to the size of its absolutely positioned child. [JSFiddle Fork](http://jsfiddle.net/yX4RK/1/)
FreekOne
@Alexander @FreekOne Thanks guys. I've fixed it and added border for container to see how it stretches.
Nikita Rybak
Whoah, thanks. I'll try it now on my page, see if it works, but it seems to be the right answer. :)
Alexander
+1 Nicely done !
FreekOne
Yes, and so simple too. Excellent! :) It works like a charm.
Alexander