Author |
Topic |
|
JJenson
Advanced Member
USA
2121 Posts |
Posted - 18 February 2009 : 13:11:43
|
Ok I have been getting really good with the whole DIV/CSS thing but I have one issue I can never seem to get around so I want to see if any of you have run into this:
I have a container div that has 3 divs inside of it.
This is the CSS to control all of it:
I basically have tried to set the height of the container div to 150px which then makes the heights right for the filler text. But this is a cms site they need to be able to add text to any box and the container div needs to grow to the right size.
The problem is I cannot seem to make all 3 divs inside the container the same height.
I know i can do this in tables and worse comes to worse I will do this one thing in it. But I want to know if there is a DIV/CSS solution so I can learn it.
Thanks for the input.< |
|
JJenson
Advanced Member
USA
2121 Posts |
Posted - 18 February 2009 : 13:43:48
|
I did fix this with JavaScript but I would like to know if anyone knows a pure CSS fix for this?< |
|
|
SiSL
Average Member
Turkey
671 Posts |
|
JJenson
Advanced Member
USA
2121 Posts |
Posted - 18 February 2009 : 14:01:02
|
But that will not grow so they will always be the same height. So if someone puts in 1000 words into the first div the second div needs to stretch to be the same length.
< |
|
|
MaD2ko0l
Senior Member
United Kingdom
1053 Posts |
Posted - 18 February 2009 : 14:20:43
|
have you had a look at the "overflow" function...
i think thats what its called. im sure i used it somwhere to filter out longwords or images that was larger than a certain box.< |
© 1999-2010 MaD2ko0l |
|
|
SiSL
Average Member
Turkey
671 Posts |
|
AnonJr
Moderator
United States
5768 Posts |
Posted - 18 February 2009 : 14:55:13
|
It can be done via CSS, but its a major PITA - you may want to check over at www.alistapart.com as I seem to remember them having an article or two over the summer on that very subject. More often than not there's a little JavaScript thrown in the mix to tie it all together. Tables (used properly) do make some of this a lot easier. I do get the whole "semantics" bit that you seem to read everywhere, but I just don't get why its such a religious quest to rid the world of table-based layouts. But that's another discussion for another day...
You may also want to look at some of the CSS frameworks that are out there to see if it wouldn't make life a little easier. www.sitepoint.com had an article on them recently.< |
Edited by - AnonJr on 18 February 2009 14:56:17 |
|
|
Shaggy
Support Moderator
Ireland
6780 Posts |
Posted - 18 February 2009 : 15:01:03
|
Float the containing div (mainContent) and give it a min-height of 150px.
< |
Search is your friend “I was having a mildly paranoid day, mostly due to the fact that the mad priest lady from over the river had taken to nailing weasels to my front door again.” |
|
|
Shaggy
Support Moderator
Ireland
6780 Posts |
Posted - 18 February 2009 : 15:13:13
|
Sorry, meant to say to give each of the child divs the min-height not the the parent.
< |
Search is your friend “I was having a mildly paranoid day, mostly due to the fact that the mad priest lady from over the river had taken to nailing weasels to my front door again.” |
|
|
JJenson
Advanced Member
USA
2121 Posts |
Posted - 18 February 2009 : 16:53:37
|
Yeah I did that but they don't all grow together that way. I have javascript that makes it work but I just wanted to know if there was a CSS solution.
I am not against tables by any means at all. But at the same time I have only used tables and I want to learn div based layouts better so I can be quicker at them so I am just trying everything is all. I can do pretty much everything else I need but multiple columns same height.< |
|
|
SiSL
Average Member
Turkey
671 Posts |
|
JJenson
Advanced Member
USA
2121 Posts |
Posted - 18 February 2009 : 20:50:53
|
SISL I understand how tables and div's work. But there are work arounds and hacks all over to make things work. I was just seeing if someone knew of any work around for div's. I already said I have javascript that will do this but wanted to ask if there was a CSS way of doing this same thing.
But I will say it is a pretty sweet script that pretty much makes all divs the same height you specify. If anyone is interested let me know I will point you to it. only takes 1 js file and 1 call on the body tag.
Anyways thanks for the suggestions. I can make the divs all the same height to a certain point but then if 1 div grows beyond that certain point it just doesn't seem to want to play. Anyways thanks for the suggestions seems like JavaScript is the way to go for this one.< |
Edited by - JJenson on 18 February 2009 20:51:53 |
|
|
Shaggy
Support Moderator
Ireland
6780 Posts |
Posted - 19 February 2009 : 04:43:11
|
See, that's why I don't post here late at night, I misread everything!
JavaScript is one way to do it, yes, but it's far from ideal. A pure-CSS way to do it would be to apply a background image to the parent div that tiles vertically and incorporates the background of the child divs.
<edit>Here's a very simple example to illustrate how you would do it. No JS, just CSS and images</edit>
<edit2>SiSL, tables should not be used to lay things out in columns, they should only be used to display information that should be tabulated.</edit2>
< |
Search is your friend “I was having a mildly paranoid day, mostly due to the fact that the mad priest lady from over the river had taken to nailing weasels to my front door again.” |
Edited by - Shaggy on 19 February 2009 05:16:56 |
|
|
JJenson
Advanced Member
USA
2121 Posts |
Posted - 19 February 2009 : 09:59:25
|
I actually figured out a where I did it this way as well:
<div1>top images with 2 columns</div> <div2>Repeated Background image with 2 internal divs to lay it out</div> <div>Bottom Image to close table off.</div>
I think that is basically what you are saying. Its pure CSS and DIV's its worked around a different way but none the less works just like it is supposed to. I have been playing around with pure divs and css and I have been loving what I have learned the only 2 issues I ever find is this one and having something at the bottom of the screen if there is not enough content to fill up the window and have it stay below window but at the bottom after you scroll if there is alot of content/
Anyways thanks Shaggy of the idea :)< |
|
|
|
Topic |
|