Another CSS Question - نوشته شده در (2224 Views)
Advanced Member
JJenson
مطلب: 2121
2121
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.

Code:

<div class="mainContent">
<div class="Box1">
<div id="content">
<h6>INTRODUCING NEWS ON HOLD</h6>
consectetur adipiscing elit. Curabitur sed neque. Nam fringilla, sapien et tempus sollicitudin, eros erat faucibus libero, sit amet faucibus odio magna vulputate pede. </div>
</div>
<div class="Box2">
<div id="content_2">
<h6>WHAT WE DO</h6>
consectetur adipiscing elit. Curabitur sed neque. Nam fringilla, sapien et tempus sollicitudin, eros erat faucibus libero, sit amet faucibus odio magna vulputate pede. </div>
</div>
<div class="Box3">
<div id="content_3">
<h6>BOTTOM LINE</h6>
consectetur adipiscing elit. Curabitur sed neque. Nam fringilla, sapien et tempus sollicitudin, eros erat faucibus libero, sit amet faucibus odio magna vulputate pede. </div>
</div>
<div style="clear:both;"></div>
</div>

This is the CSS to control all of it:

Code:

.mainContent { position: relative; width: 715px; margin: 10px auto 70px; }

.mainContent .Box1 { position: relative; height: 100%; float: left; width: 200px; border: 1px solid #0092CF; }
.mainContent .Box1 #content { padding: 10px 15px; }
.mainContent .Box1 #content h6 { font-size: 11px; margin: 0px 0px 5px; }

.mainContent .Box2 { position: relative; height: 100%; float: left; width: 265px; margin: 0px 0px 0px 20px; border: 1px solid #0092CF; }
.mainContent .Box2 #content_2 { padding: 10px 15px; }
.mainContent .Box2 #content_2 h6 { font-size: 11px; margin: 0px 0px 5px; }

.mainContent .Box3 { position: relative; height: 100%; float: left; width: 204px; margin: 0px 0px 0px 20px; border: 1px solid #0092CF; }
.mainContent .Box3 #content_3 { padding: 10px 15px; }
.mainContent .Box3 #content_3 h6 { font-size: 11px; margin: 0px 0px 5px; }


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.<
 پیش‌فرض مرتب‌سازی برای تاریخ DESC به معنی جدیدترین است  
 تعداد در صفحه 
نوشته شده در
Advanced Member
JJenson
مطلب: 2121
2121
I did fix this with JavaScript but I would like to know if anyone knows a pure CSS fix for this?<
نوشته شده در
Average Member
SiSL
مطلب: 671
671
نوشته شده در
Advanced Member
JJenson
مطلب: 2121
2121
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.
<
نوشته شده در
Senior Member
MaD2ko0l
مطلب: 1053
1053
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
نوشته شده در
Average Member
SiSL
مطلب: 671
671
From what you told, I understand, you want other divs to enlarge, if one of them has enlarged too... That would be only made by tables mate, it is not CSS's duty to check different div's heights.

other than that, if you want it strict 150px, but viewer able to see entire text

{ height: 150px; overflow-y: scroll; }

<
نوشته شده در
Forum Moderator
AnonJr
مطلب: 5768
5768
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.<
نوشته شده در
Support Moderator
Shaggy
مطلب: 6780
6780
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.”
نوشته شده در
Support Moderator
Shaggy
مطلب: 6780
6780
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.”
نوشته شده در
Advanced Member
JJenson
مطلب: 2121
2121
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.<
نوشته شده در
Average Member
SiSL
مطلب: 671
671
That's not possible JJenson that the two divs change their height according to one other's height unless DHTML/Javascript feed. Divs does not work like tables and both have their respective ways where to use one or the other... You have just recieved one step: If you want an aligned/same scalable parts, that's table's job...<
شما باید یک متن وارد کنید