JSFiddle - React, Tailwind, and code Playground

by arcm111

HTML

<body>
    <ul><li id="root"><p>Root</p></li></ul>
</body>

CSS

body {
	font-family: arial;
	background: #eee;
	font-size: 14px;
	color: #7861a0;
}

ul{
	display: table;
	list-style-type: none;
	padding: 0;
	margin: 0;
}

li {
	display: table-cell;
	text-align: center;
	padding: 0;
	margin: 0;
}

p {
	margin: 0 0 5px 0;
	position: relative;
	min-width: 100px;
	padding: 4px 10px 12px;
}

p:before {
	content: "";
	display: block;
	width: 50%;
	height: 10px;
	position: absolute;
	top: -10px;
	left: 50%;
	border-top: 1px solid #000;
	border-left: 1px solid #000;
}

li:last-child>p:before {
	width: 0;
	border-top: none;
	border-left: none;
	border-right: 1px solid #000;
}

p:after {
	content: "";
	display: block;
	width: 50%;
	height: 0px;
	position: absolute;
	top: -10px;
	right: 50%;
	border-top: 1px solid #000;
	border-right: 1px solid #000;
}

li:first-child>p:after {
	width: 0;
	top: 0;
	right: 0;
	border-top: none;
	border-right: none;
}

JavaScript

var root = document.getElementById("root");

function tree(item, n)
{
    var list, ul, li, p;
    list = document.createElement('ul');
    item.appendChild(list);
    for (var i = 0; i < 1; i++)
    {
        li = document.createElement('li');
        li.innerHTML = "<p>parent " + (n + 1) + "</p>";
        list.appendChild(li);
        if (n < 100) tree(li, n + 1);
    }
}

tree(root, 0);