In HTML/CSS I want to display a data-tree in the following form: The root node is on the left side. Parent nodes are to the left of child nodes and the first child is always on the same line as the parent. The sibling nodes are on the lines below.
See this example. The lines are just illustrative here to understand the relationships.
1 - 1.1 - 1.1.1
\ ` 1.1.2
`1.2 - 1.2.1
2 - 2.1
`2.2
I want to have the child nodes connected with their parents so that, when I e.g. drag-drop the parents, all the connected child nodes move too. Thats why I chose a nested-approach.
My approach:
<div><p> some text </p><div> recursively add the children here </div></div>
Each node I add like this
$(document.createElement('div'))
.appendTo(parent)
.css('overflow', 'auto')
.append($(document.createElement('p'))
.css('float', 'left')
.html(some text)
.append($(document.createElement('div'))
.css('overflow', 'auto'));
My problem with the approach: When the tree gets larger than the container it wraps to the next line. However I want the effect of overflow:hidden. This css tag on the container has no effect with left-floating items.
jsFiddle: See this jsFiddle for an example: http://jsfiddle.net/Afasv/8/ The first one is what the tree looks like in a too tight container, the second it has enough space and in the third I am using a hack where I place the tree within a div larger than the outer container.
Any ideas for a solution would be appreciated!