Advertisement
saltun

HTML and CSS Tree

Apr 20th, 2014
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.69 KB | None | 0 0
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <style type="text/css">
  6.  
  7. * {margin: 0; padding: 0;}
  8.  
  9. .tree ul {
  10.     padding-top: 20px; position: relative;
  11.    
  12.     transition: all 0.5s;
  13.     -webkit-transition: all 0.5s;
  14.     -moz-transition: all 0.5s;
  15. }
  16.  
  17. .tree li {
  18.     float: left; text-align: center;
  19.     list-style-type: none;
  20.     position: relative;
  21.     padding: 20px 5px 0 5px;
  22.    
  23.     transition: all 0.5s;
  24.     -webkit-transition: all 0.5s;
  25.     -moz-transition: all 0.5s;
  26. }
  27.  
  28.  
  29.  
  30. .tree li::before, .tree li::after{
  31.     content: '';
  32.     position: absolute; top: 0; right: 50%;
  33.     border-top: 1px solid #ccc;
  34.     width: 50%; height: 20px;
  35. }
  36. .tree li::after{
  37.     right: auto; left: 50%;
  38.     border-left: 1px solid #ccc;
  39. }
  40.  
  41.  
  42. .tree li:only-child::after, .tree li:only-child::before {
  43.     display: none;
  44. }
  45.  
  46.  
  47. .tree li:only-child{ padding-top: 0;}
  48.  
  49. .tree li:first-child::before, .tree li:last-child::after{
  50.     border: 0 none;
  51. }
  52.  
  53. .tree li:last-child::before{
  54.     border-right: 1px solid #ccc;
  55.     border-radius: 0 5px 0 0;
  56.     -webkit-border-radius: 0 5px 0 0;
  57.     -moz-border-radius: 0 5px 0 0;
  58. }
  59. .tree li:first-child::after{
  60.     border-radius: 5px 0 0 0;
  61.     -webkit-border-radius: 5px 0 0 0;
  62.     -moz-border-radius: 5px 0 0 0;
  63. }
  64.  
  65.  
  66. .tree ul ul::before{
  67.     content: '';
  68.     position: absolute; top: 0; left: 50%;
  69.     border-left: 1px solid #ccc;
  70.     width: 0; height: 20px;
  71. }
  72.  
  73. .tree li a{
  74.     border: 1px solid #ccc;
  75.     padding: 5px 10px;
  76.     text-decoration: none;
  77.     color: #666;
  78.     font-family: arial, verdana, tahoma;
  79.     font-size: 11px;
  80.     display: inline-block;
  81.    
  82.     border-radius: 5px;
  83.     -webkit-border-radius: 5px;
  84.     -moz-border-radius: 5px;
  85.    
  86.     transition: all 0.5s;
  87.     -webkit-transition: all 0.5s;
  88.     -moz-transition: all 0.5s;
  89. }
  90.  
  91.  
  92. .tree li a:hover, .tree li a:hover+ul li a {
  93.     background: #c8e4f8; color: #000; border: 1px solid #94a0b4;
  94. }
  95.  
  96. .tree li a:hover+ul li::after,
  97. .tree li a:hover+ul li::before,
  98. .tree li a:hover+ul::before,
  99. .tree li a:hover+ul ul::before{
  100.     border-color:  #94a0b4;
  101. }
  102.  
  103. </style>
  104. </head>
  105. <body>
  106.     <div class="tree">
  107.     <ul>
  108.         <li>
  109.             <a href="#">Parent</a>
  110.             <ul>
  111.                 <li>
  112.                     <a href="#">Child</a>
  113.                     <ul>
  114.                         <li>
  115.                             <a href="#">Grand Child</a>
  116.                         </li>
  117.                     </ul>
  118.                 </li>
  119.                 <li>
  120.                     <a href="#">Child</a>
  121.                     <ul>
  122.                         <li><a href="#">Grand Child</a></li>
  123.                         <li>
  124.                             <a href="#">Grand Child</a>
  125.                             <ul>
  126.                                 <li>
  127.                                     <a href="#">Great Grand Child</a>
  128.                                 </li>
  129.                                 <li>
  130.                                     <a href="#">Great Grand Child</a>
  131.                                 </li>
  132.                                 <li>
  133.                                     <a href="#">Great Grand Child</a>
  134.                                 </li>
  135.                             </ul>
  136.                         </li>
  137.                         <li><a href="#">Grand Child</a></li>
  138.                     </ul>
  139.                 </li>
  140.             </ul>
  141.         </li>
  142.     </ul>
  143. </div>
  144. </body>
  145. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement