Building Pure CSS Trees (part 2)
fractaledmind.com·1d
🎨Modern CSS
Preview
Report Post

In our last post, we built a simple pure-CSS tree from a nested list. That tree was horizontally oriented, but what if we wanted a vertically oriented tree? Today, let’s build that.


We left our tree last in this state:

See the Pen css-tree__8 by Stephen Margheim (@smargh) on CodePen.

Let’s take that same HTML, the lessons we learned from our horizontal tree, and start over to build a vertically oriented tree. We can start with our basic .tree styles, our node styles, our our li styles; however, we will need to flip the flex-direction of the lis:

.tree {  list-style: none;  &,  * {    margin: 0;    padding: 0;  }  li {   ...

Similar Posts

Loading similar posts...