By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,035 Members | 1,471 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,035 IT Pros & Developers. It's quick & easy.

applying indent on divs i a tree structure

P: n/a
Hi,

I need to apply some indenting (margin) on my divs. I have a forum
which uses a tree structure so that the users will be able to see which
user replies to what topic.

Is there some kind of "easy" way to go though my divs and apply
leftmargin style on my divs so that indent? Please be aware of there
can be an unlimited number of levels.

Here is my html:

<div id="a">topic 1</div>
<div id="b">repley</div>
<div id="b">repley</div>
<div id="c">repley</div>
<div id="c">repley</div>
<div id="d">repley</div>
<div id="d">repley</div>
<div id="c">repley</div>
<div id="b">repley</div>
<div id="a">indlęg</div>

Jan 26 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
If you cannot change html:

<style>
#a{padding-left:10px}
#b{padding-left:20px}
#c{padding-left:30px}
#d{padding-left:40px}

etc...

</style>
<div id="a">topic 1</div>
<div id="b">repley</div>
<div id="b">repley</div>
<div id="c">repley</div>
<div id="c">repley</div>
<div id="d">repley</div>
<div id="d">repley</div>
<div id="c">repley</div>
<div id="b">repley</div>
<div id="a">indflag</div>
But if you can change html it seems for me more preferable is next
html:
<style>
div{padding-left: 10;display:block}
</style>
<div>topic 1
<div>repley</div>
<div>repley
<div>repley</div>
<div>repley
<div>repley</div>
<div>repley</div>
</div>
<div>repley</div>
</div>
<div>repley</div>
</div>
<div>indflag</div>

Jan 26 '06 #2

P: n/a
On 2006-01-26, la************@gmail.com <la************@gmail.com> wrote:
Hi,

I need to apply some indenting (margin) on my divs. I have a forum
which uses a tree structure so that the users will be able to see which
user replies to what topic.

Is there some kind of "easy" way to go though my divs and apply
leftmargin style on my divs so that indent? Please be aware of there
can be an unlimited number of levels.

Here is my html:

<div id="a">topic 1</div>
<div id="b">repley</div>
<div id="b">repley</div>
<div id="c">repley</div>
<div id="c">repley</div>
<div id="d">repley</div>
<div id="d">repley</div>
<div id="c">repley</div>
<div id="b">repley</div>
<div id="a">indlęg</div>


you shouldn't repeat the same id like that.

changing the the HTML to reflect the structure will probably help too.

(<ul> might be better suited)

<div>a_topic
<ul><li>b_repley</li>
<li>b_repley
<ul><li>c_repley</li>
<li>c_repley
<ul><li>d_repley</li>
<li>d_repley</li>
</ul></li>
<li>c_repley</li>
</ul></li>
<li>b_repley</li>
</ul>
indlęg
</div>

that'll probably still need some styling, but probably much less.

Bye.
Jasen
Jan 27 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.