Forum Moderators: not2easy

Message Too Old, No Replies

Nested divs layout

         

juanjo

10:34 am on Jan 7, 2004 (gmt 0)

10+ Year Member



How can I override the default layout of nested divs (i.e. vertical)?

I want to do something like a table row but only with divs, is it possible?

Thanks

Safir

10:59 am on Jan 7, 2004 (gmt 0)

10+ Year Member



Welcome to Webmaster World!

you can do this:


<html>
<head>
<title>test</title>
<style>
div{display: inline;}
</style>
</head>
<body>
<div><div>1</div><div>2</div><div>3</div><div>...</div></div>
</body>
</html>

But i'm quite sure what you're trying is more complex... Try searching this forum because there is alot of information about this here!

IeuanJ

11:53 am on Jan 7, 2004 (gmt 0)

10+ Year Member



Look around for information on the following attributes :

1) display
2) position
3) float

These are the basic atributes to allow you to position your divs around the page and each other.

juanjo

5:44 pm on Jan 7, 2004 (gmt 0)

10+ Year Member



Safir, thanks for your tip. I've been playing with your sample and now I understand better the display attribute.

I already had tried to do it with "display: inline" but I was putting it in the container, not in children.

The disadvantage of "inline" is that the "width" attribute is ignored. But I've found another value for display attribute that works fine with widths: "table-cell".

So, my solution will be something like this:


<style>
.celldiv {display: table-cell; width: 25%;}
</style>
...
<div>
<div class="celldiv">1</div>
<div class="celldiv">2</div>
<div class="celldiv">3</div>
<div class="celldiv">...</div>
</div>

wich is good enough for my requirements.

Safir

6:09 pm on Jan 7, 2004 (gmt 0)

10+ Year Member



this will do the same:

<style>
div#safir div{display:table-cell; width:25%}
</style>

<div id="safir">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
</div>

This way you say: use this style for all div's decending from the div with id="safir"