Advertisement
Virajsinh

Family Tree HTML Design.html

Jul 17th, 2025
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.79 KB | Source Code | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>Family Tree</title>
  6.     <style>
  7.         * {
  8.             box-sizing: border-box;
  9.         }
  10.  
  11.         .tree {
  12.             margin: 50px auto;
  13.             text-align: center;
  14.             font-family: Arial, sans-serif;
  15.         }
  16.  
  17.         .tree ul {
  18.             padding-top: 20px;
  19.             position: relative;
  20.             display: flex;
  21.             justify-content: center;
  22.         }
  23.  
  24.         .tree li {
  25.             list-style: none;
  26.             position: relative;
  27.             padding: 20px 5px 0 5px;
  28.             text-align: center;
  29.         }
  30.  
  31.         .tree li::before, .tree li::after {
  32.             content: '';
  33.             position: absolute;
  34.             top: 0;
  35.             border-top: 2px solid #ccc;
  36.             width: 50%;
  37.             height: 20px;
  38.         }
  39.  
  40.         .tree li::before {
  41.             right: 50%;
  42.             border-right: 2px solid #ccc;
  43.         }
  44.  
  45.         .tree li::after {
  46.             left: 50%;
  47.             border-left: 2px solid #ccc;
  48.         }
  49.  
  50.         .tree li:only-child::before,
  51.         .tree li:only-child::after {
  52.             content: none;
  53.         }
  54.  
  55.         .tree li:first-child::before,
  56.         .tree li:last-child::after {
  57.             border: none;
  58.         }
  59.  
  60.         .tree .node {
  61.             display: inline-block;
  62.             padding: 10px 20px;
  63.             border: 2px solid #4285f4;
  64.             background-color: #e3f2fd;
  65.             border-radius: 8px;
  66.             font-weight: bold;
  67.             position: relative;
  68.             z-index: 1;
  69.         }
  70.  
  71.         /* vertical line down from parent */
  72.         .tree ul::before {
  73.             content: '';
  74.             position: absolute;
  75.             top: 0;
  76.             left: 50%;
  77.             border-left: 2px solid #ccc;
  78.             height: 20px;
  79.         }
  80.  
  81.         .tree ul:only-child::before {
  82.             display: none;
  83.         }
  84.  
  85.     </style>
  86. </head>
  87. <body>
  88.  
  89.     <div class="tree">
  90.         <ul>
  91.             <li>
  92.                 <div class="node">A</div>
  93.                 <ul>
  94.                     <li>
  95.                         <div class="node">B</div>
  96.                         <ul>
  97.                             <li><div class="node">D</div></li>
  98.                             <li><div class="node">E</div></li>
  99.                         </ul>
  100.                     </li>
  101.                     <li><div class="node">C</div></li>
  102.                 </ul>
  103.             </li>
  104.         </ul>
  105.     </div>
  106.  
  107. </body>
  108. </html>
  109.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement