HTML
<link rel="stylesheet" href="tree.css" />
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />
<div class="tree">
<ul>
<li><i class="fa fa-folder-open"></i> Project
<ul>
<li><div class="e"><i class="fa fa-folder-open"></i><p class="x"> Opened Folder </p><p class="line"></p><p class="s">: Folder for xxx</p></div>
<ul>
<li><i class="fa fa-folder-open"></i> css
<ul>
<li><div class="e"><i class="fa fa-file"></i><p class="x"> CSS File </p><p class="line"></p><p class="s">: File for xxx</p></div>
</li>
</ul>
</li>
<li><i class="fa fa-folder"></i> Folder close <span class="b">: Folder for yyyy</span>
</li>
<li><i class="fab fa-html5"></i> index.html</li>
<li><i class="fa fa-picture-o"></i> favicon.ico</li>
</ul>
</li>
<li><i class="fa fa-folder"></i> Folder close <span class="b">: Folder for zzzzz</span>
</li>
</ul>
</li>
</ul>
</div>
CSS
:root {
--main-bg-color: white;
--main-pad-size: 10px;
--desc-area-width: 50vw;
}
body {
font-size: 1rem;
background: #f5f5f5;
}
.tree {
position: relative;
background: white;
margin-top: 20px;
padding: 30px;
font-size: .85rem;
font-weight: 400;
line-height: 1.5;
color: #212529;
}
.tree .fa-folder-open, .tree .fa-folder {
color: #007bff;
}
.tree .fa-file {
color: #50c878;
}
.tree ul {
padding-left: 5px;
list-style: none;
}
.tree ul li {
position: relative;
padding: 5px 0px 5px 15px;
box-sizing: border-box;
}
.tree ul li:before {
position: absolute;
top: 15px;
left: 0;
width: 10px;
height: 1px;
margin: auto;
content: '';
background-color: #666;
}
.tree ul li:after {
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 1px;
height: 100%;
content: '';
background-color: #666;
}
.tree ul li:last-child:after {
height: 15px;
}
.tree div.e {
display: flex;
flex-direction: row;
}
i {
background-color: var(--main-bg-color);
margin: auto 0;
z-index: 10;
}
.tree p.x {
position: relative;
background-color: var(--main-bg-color);
margin: 0;
padding: 0 var(--main-pad-size);
z-index: 10;
}
.tree p.line {
position: absolute;
top: 15px;
width: calc(100% - var(--desc-area-width));
height: 1px;
border-color: #bbb;
border-style: dotted none none;
margin: 0;
z-index: 0;
}
.tree p.s {
width: var(--desc-area-width);
background-color: var(--main-bg-color);
margin: 0 0 0 auto;
padding-left: var(--main-pad-size);
z-index: 10;
}
Typora
<iframe src="tree.html" style="width:100%;height:100vh"></iframe>
参考
CSSでフォルダツリーを作る
Result See the Pen File Tree CSS by kachibito (@kachibito) on CodePen.こういうの。まぁ特別なものでもないんですがコードがすっきりしてたのでメモCMSの管理画面なんかで