tags:

views:

393

answers:

4

I have a floating div with dynamic content in it. In the first row i need four divs, similarly in 2nd, 3rd ,4th etc... i need four divs. I can assign a class to a single div and it will automatically generate the rest of the divs. My problem is i can set the min-height to a div, but i cannot set the max height as the content is dynamically created. if the content is low the divs are not sitting in a straight row. for this reasons, the up coming divs also getting problem, how to arrange these divs?

A: 

One thing you can do is make the height fixed, and use overflow CSS property set to hide to hide the text, and use the title attribute to show the whole text in a tooltip.

Kirtan
I cann't have a fixed height, coz when the content is low, there will be lot of spacing...
Webdevelopertut
+1  A: 

Let's get this straight. You have multiple rows with 4 DIVs in each - let's call them cells just for fun. You want their height to be the same across the entire row while having dynamic content. I'm going to go out on a limb here and suggest you use a table.

ChssPly76
Hmmmm. But then also he'll have lot of spacing when the content is low, and he doesn't want it. See the comment on the answer below.
Kirtan
I believe his comment to your answer meant that if he were to set a fixed height *big enough* to accommodate longest possible content in any of the divs, then in the situation when content in *all divs* turns out to be shorter he'll have spacing in all of them. What he really wants is to have one div (the one with longest content) be high enough to accommodate its content with no spacing and all others to be the same height as this div (and have spacing). In other words - classic table behavior. The only way to do that without tables is via JS, CSS-only solution is impossible.
ChssPly76
+1  A: 

On the first div the the new row, add clear:both;. That will make all the divs in a straight row.

div {float:left;border:1px solid #000;margin:20px;width:100px;}
.clear_both{clear:both;}
.one {height:100px;}
.two {height:50px;}
.three {height:200px;}
.four {height:150px;}

<div class="one"></div>
<div class="two"></div>
<div class="three"></div>
<div class="four"></div>
<div class="two clear_both"></div>
<div class="three"></div>
<div class="four"></div>
<div class="one"></div>
Emily
I don't think that's what **Webdevelopertut** is asking, though his question is not exactly clear. But since he's talking about div heights I take his "straight row" notion to mean "have all divs in the same row to be of the same height".
ChssPly76