Skip to content

Instantly share code, notes, and snippets.

@bsakhanov
Created January 24, 2019 13:19
Show Gist options
  • Save bsakhanov/1e7fe1f9e83de3355a41702b64686585 to your computer and use it in GitHub Desktop.
Save bsakhanov/1e7fe1f9e83de3355a41702b64686585 to your computer and use it in GitHub Desktop.
Vertical tree table, organization structure
<ul class="treeCSS">
<li><b>Руководитель</b>
<ul>
<li>1-й Заместитель </br>руководителя
<ul>
<li>Директор </br>1-го департамента
<ul>
<li>начальник </br>1-го отдела
<li>начальник </br>2-го отдела
<li>начальник </br>3-го отдела
</ul>
<li>Директор </br>2-го департамента
<li>Директор </br>3-го департамента
</ul>
<li>2-й Заместитель </br>руководителя
<ul>
<li>Директор </br>1-го департамента
<ul>
<li>начальник </br>1-го отдела
<li>начальник </br>2-го отдела
<li>начальник </br>3-го отдела
</ul>
<li>Директор </br>2-го департамента
<li>Директор </br>3-го департамента
</ul>
</ul>
</ul>
.treeCSS,
.treeCSS ul {
position: relative;
display: table;
margin: 5px 0 0 0 !important;
padding: 6px 0 0 0 !important;
line-height: normal;
text-align: center;
word-wrap: break-word;
word-break: break-all;
}
.treeCSS li {
position: relative;
display: table-cell;
}
/* Отступ между пунктами */
.treeCSS li:not(:only-child) {
padding: 0 .5em;
}
.treeCSS li:last-child {
padding-right: 0;
}
.treeCSS li:first-child {
padding-left: 0;
}
/* Линии */
.treeCSS ul:before,
.treeCSS ul li:before,
.treeCSS ul li:after {
content: "";
position: absolute;
top: -5px;
left: 0;
width: 50%;
height: 5px;
border-right: 1px solid #999;
}
.treeCSS ul:before {
top: -4px;
}
.treeCSS ul li:not(:only-child):before {
border-top: 1px solid #999;
}
.treeCSS ul li:not(:only-child):first-child:before {
right: 0;
left: auto;
border-left: 1px solid #999;
border-right: none;
}
.treeCSS ul li:not(:only-child):first-child:before,
.treeCSS ul li:not(:only-child):last-child:before { /* необязательно, 0.5 взят из свойства padding в селекторе .treeCSS li:not(:only-child) */
width: calc(50% + .5em/2);
}
.treeCSS ul li:after {
border: none;
}
.treeCSS ul li:not(:last-child):not(:first-child):after {
width: 100%;
border-top: 1px solid #999;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment