Is this possible to create a tree component using only HTML and CSS that contains lines connecting nodes? I'm trying to avoid nested nodes containing text with CSS styles
See the mockup as an example. It heavily inspired by Autodesk Maya inspector tree
I achieved the following but I don't like it because the lines are not connected:
https://codepen.io/xotonic/pen/JRLAOR
HTML:
<ul>
<li class="container"><p><r>Testing</r> </p>
<ul>
<li><p><r>Testing 1</r></p></li>
<li><p><r>Testing 2</r></p></li>
<li class="container"><p><r>Testing</r> </p>
<ul>
<li><p><r>Testing 1</r></p></li>
<li><p><r>Testing 2</r></p></li>
<li><p><r>Testing 3</r></p></li>
</ul>
</li>
</ul>
</li>
<li class="container"><p><r>Testing</r> </p>
<ul>
<li><p><r>Testing 1</r></p></li>
<li><p><r>Testing 2</r></p></li>
<li><p><r>Testing 3</r></p></li>
</ul>
</li>
<li class="container"><p><r>Testing </r></p>
<ul>
<li class="empty"><p><r>empty</r></p></li>
</ul>
</li>
CSS:
ul, li { list-style: none; margin: 0; padding: 0; }
ul { padding-left: 1em; }
li { padding-left: 1em;
border: 1px dotted black;
border-width: 0 0 1px 1px;
}
li.container { border-bottom: 0px;
}
li.empty { font-style: italic;
color: silver;
border-color: silver;
}
p { margin: 0;
background: white;
position: relative;
top: 0.5em;
}
p:before {
content: '';
position: absolute;
width: 1em;
border: 1px solid black;
height: 1em;
border-radius: 1em;
margin-left: 0.5em;
}
r {
margin-left: 2em;
}
ul {
border-top: 1px dotted black;
margin-left: -1em;
padding-left: 2em;
}
ul li:last-child ul {
border-left: 1px solid white;
margin-left: -17px;
}
:before
pseudo-element to draw circle in content div, but lines drawing to the div instead circle.