1 (edited by chrizz 2005-04-10 11:50)

Topic: A DIV height issue (with example)

A wrap, a margin div and a content div:

<div class="wrap">
     <div class="margin" style="WIDTH: 150px; FLOAT: left"> 
     ... some content that stretches this div on the height for about 1500px or something large...
     </div>

     <div class="content" style="WIDTH: 400px; FLOAT: left; BACKGROUND-COLOR: red">
     ...content that streches this div on the height for only 500px (less than the margin div)...
     </div>
</div>

Now, the issue is I want the div with the red background color (the content div) to allways have the same height (or more, but NOT less) as the margin div.

The code above in "action": http://www.garaget.org/temp/asdf.html

Thanks.

/C

Edit: the classes are empty and are shown only for examplification

2

Re: A DIV height issue (with example)

Does the content div have to be a float?

Re: A DIV height issue (with example)

Well, what do you suggest instead?

4

Re: A DIV height issue (with example)

Is this anything like you want
http://www.post21.co.uk/files/layout2col.html
If not it can be adapted.

5 (edited by chrizz 2005-04-10 13:48)

Re: A DIV height issue (with example)

The idea is the same, but mine is a bit more complicated. Here is the actual code (a bit modified so it works). Notice that the wrap have a black background set but the background never becomes black all the way down.

<style>
DIV.wrapmiddle { BACKGROUND-COLOR: #000000}
</style>

<div class="wrapmiddle">
    <div style="WIDTH: 25px; FLOAT: left"> </div> <!-- Empty space border //-->
    <div class="middlemargin" style="FLOAT: left; WIDTH: 160px;">
        
        Margin<br />
        asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf 
        
    </div>
    <div style="WIDTH: 7px; FLOAT: left;"> </div> <!-- Empty space border //-->
    
    <div style="WIDTH: 699px; FLOAT: left; BACKGROUND-COLOR: green;">
        
        <div style="BACKGROUND-IMAGE: url('/images/layout/conwin-brd_top.gif'); HEIGHT: 7px; BACKGROUND-COLOR: #FFFFFF; BACKGROUND-POSITION: top left; BACKGROUND-REPEAT: no-repeat; FONT-SIZE: 0px"></div>
        <div>
            <div style="FLOAT: left; WIDTH: 6px;"> </div> <!-- Empty space border //-->
            <div style="FLOAT: left">
            
            Content
            asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf 
            
            </div>
            <div style="FLOAT: left; WIDTH: 6px"> </div> <!-- Empty space border //-->
        </div>
        <div style="BACKGROUND-IMAGE: url('/images/layout/conwin-brd_bottom.gif'); HEIGHT: 7px; BACKGROUND-POSITION: bottom left; BACKGROUND-REPEAT: no-repeat; FONT-SIZE: 0px; CLEAR: both;"></div>
        </div>
    </div>
    <div style="WIDTH: 25px; FLOAT: left"> </div>
    <div style="CLEAR: both"></div>
</div>

Example of how this looks:
http://www.garaget.org/temp/asdf.html (Without any images)

Re: A DIV height issue (with example)

Ive tried to solve the spacing things with MARGIN and/or PADDING but it get so messed up with other div sizes, and when it works in IE, it does not work in FF, and when it works in FF it does not work in IE and so on sad

7

Re: A DIV height issue (with example)

The reason you are not getting the black background is that you have a clossing </div> that shouldn't be there. It's 5 lines from the bottom.

This should be easy to do but I can't quite see what you want the final result to be. Do you just want two boxes floating on a black background with a black border around everything and some space between the boxes?

8 (edited by chrizz 2005-04-10 14:14)

Re: A DIV height issue (with example)

Its hard for me to explain, so I edited the actual page in PS:

This is how it is now and how I DONT want it:
http://www.garaget.org/temp/gorg-wrong.jpg

This is how I want it to be:
http://www.garaget.org/temp/gorg-correct.jpg

9

Re: A DIV height issue (with example)

OK. Give me a few minutes.

EDIT: is the whole layout supposed to be fixed width, if so how wide.

10 (edited by chrizz 2005-04-10 14:37)

Re: A DIV height issue (with example)

916px total, including the shadows (wich actually is an background image 916x10px instead of the black background I mentioned before)

The page is in three parts. a top, a middle and a bottom. The problem part (the code I pasted before) is only the middle part.

11

Re: A DIV height issue (with example)

What about this
http://www.post21.co.uk/files/ctest.html

Re: A DIV height issue (with example)

i think that only works in IE?

13

Re: A DIV height issue (with example)

Tested in IE6, Opera 7, Firefox, Mozilla. Identical in all of them. Even seems to work reasonably well in IE5.

Re: A DIV height issue (with example)

it didn't work in my firefox, but it does now hmm before the white box was only as low as the black bordered one inside it

15

Re: A DIV height issue (with example)

Thats because you looked at the file while I was in the middle of tidying it up. I've altered it slightly to put the width on an extra outer div so internal padding and margins can be set without screwing up the overall width.

16 (edited by chrizz 2005-04-10 21:02)

Re: A DIV height issue (with example)

It's hard for me to implement you suggestion Paul, I've tried and started over 5 times now, but i'll try some more tomorrow. The design on the page is not that basic as you suggest... if you look at www.garaget.org (the html is the old one wich im rewriting now). The design though should be identical.

But i'll try to modify your suggestion again tomorrow and maybe i'll make it work like I want it..

17

Re: A DIV height issue (with example)

I've got to be honest, if it were me I would put the content area in a 3 column 1 row table styled with css. You get a solid framework which won't cause any problems and will use less markup than the the alternatives. To get the tableless solutions to work cross browser could be a major problem. In particular, if you drop PunBB into the middle of what I proposed or what you tried it won't work.

18

Re: A DIV height issue (with example)

yes, that has been my solotion to it before but since its "not recomended" to use table for layout and design I thought to give it a try with divs only

19

Re: A DIV height issue (with example)

In that case, cheat, use faux columns i.e. change you background graphic so the central part of it is white instead of black and that will create a full height white content area. Basically you are just positioning your divs on top of a colour mask. There is nothing to loose since you are using a background graphic anyway.

20 (edited by chrizz 2005-04-10 21:55)

Re: A DIV height issue (with example)

nah, I dont like that solution smile My bakground image is 250 bytes large. If I do like you suggested it will by much larger, but anyway, I think i'll use a table to stretch the divs out to the height I want them and I just have to accept that the layout is not 100% div based. But anyway, who cares, it still can be xhtml 1.0 strict smile

21

Re: A DIV height issue (with example)

Well the text book that is usually cited as the bible of modern design in Zeldmans "Designing with web standards". Interestingly the example worked through in that book is a design which uses a simple table to give structure. Even the geeks seem to recognise that in the real world the thing has got to work.

22

Re: A DIV height issue (with example)

Then a table it is. Thanks for all your help!