Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Family Tree</title>
- <style>
- * {
- box-sizing: border-box;
- }
- .tree {
- margin: 50px auto;
- text-align: center;
- font-family: Arial, sans-serif;
- }
- .tree ul {
- padding-top: 20px;
- position: relative;
- display: flex;
- justify-content: center;
- }
- .tree li {
- list-style: none;
- position: relative;
- padding: 20px 5px 0 5px;
- text-align: center;
- }
- .tree li::before, .tree li::after {
- content: '';
- position: absolute;
- top: 0;
- border-top: 2px solid #ccc;
- width: 50%;
- height: 20px;
- }
- .tree li::before {
- right: 50%;
- border-right: 2px solid #ccc;
- }
- .tree li::after {
- left: 50%;
- border-left: 2px solid #ccc;
- }
- .tree li:only-child::before,
- .tree li:only-child::after {
- content: none;
- }
- .tree li:first-child::before,
- .tree li:last-child::after {
- border: none;
- }
- .tree .node {
- display: inline-block;
- padding: 10px 20px;
- border: 2px solid #4285f4;
- background-color: #e3f2fd;
- border-radius: 8px;
- font-weight: bold;
- position: relative;
- z-index: 1;
- }
- /* vertical line down from parent */
- .tree ul::before {
- content: '';
- position: absolute;
- top: 0;
- left: 50%;
- border-left: 2px solid #ccc;
- height: 20px;
- }
- .tree ul:only-child::before {
- display: none;
- }
- </style>
- </head>
- <body>
- <div class="tree">
- <ul>
- <li>
- <div class="node">A</div>
- <ul>
- <li>
- <div class="node">B</div>
- <ul>
- <li><div class="node">D</div></li>
- <li><div class="node">E</div></li>
- </ul>
- </li>
- <li><div class="node">C</div></li>
- </ul>
- </li>
- </ul>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement