|
| 1 | +* { |
| 2 | + margin: 0; |
| 3 | + padding: 0; |
| 4 | + font-family: sans-serif, Arial; |
| 5 | + font-size: 10pt; |
| 6 | +} |
| 7 | + |
| 8 | +.tree { |
| 9 | + white-space: nowrap; |
| 10 | + min-width: 800px; |
| 11 | + min-height: 500px; |
| 12 | +} |
| 13 | + |
| 14 | +.tree ul { |
| 15 | + padding-top: 20px; |
| 16 | + position: relative; |
| 17 | + transition: all 0.5s; |
| 18 | + -webkit-transition: all 0.5s; |
| 19 | + -moz-transition: all 0.5s; |
| 20 | +} |
| 21 | + |
| 22 | +.tree li { |
| 23 | + float: left; |
| 24 | + text-align: center; |
| 25 | + list-style-type: none; |
| 26 | + position: relative; |
| 27 | + padding: 20px 5px 0 5px; |
| 28 | + transition: all 0.5s; |
| 29 | + -webkit-transition: all 0.5s; |
| 30 | + -moz-transition: all 0.5s; |
| 31 | +} |
| 32 | + |
| 33 | +/*We will use ::before and ::after to draw the connectors*/ |
| 34 | +.tree li::before, |
| 35 | +.tree li::after { |
| 36 | + content: ''; |
| 37 | + position: absolute; |
| 38 | + top: 0; |
| 39 | + right: 50%; |
| 40 | + border-top: 1px solid #ccc; |
| 41 | + width: 50%; |
| 42 | + height: 20px; |
| 43 | +} |
| 44 | + |
| 45 | +.tree li::after { |
| 46 | + right: auto; |
| 47 | + left: 50%; |
| 48 | + border-left: 1px solid #ccc; |
| 49 | +} |
| 50 | + |
| 51 | +/*We need to remove left-right connectors from elements without any siblings*/ |
| 52 | +.tree li:only-child::after, |
| 53 | +.tree li:only-child::before { |
| 54 | + display: none; |
| 55 | +} |
| 56 | + |
| 57 | +/*Remove space from the top of single children*/ |
| 58 | +.tree li:only-child { |
| 59 | + padding-top: 0; |
| 60 | +} |
| 61 | + |
| 62 | +/*Remove left connector from first child and right connector from last child*/ |
| 63 | +.tree li:first-child::before, |
| 64 | +.tree li:last-child::after { |
| 65 | + border: 0 none; |
| 66 | +} |
| 67 | + |
| 68 | +/*Adding back the vertical connector to the last nodes*/ |
| 69 | +.tree li:last-child::before { |
| 70 | + border-right: 1px solid #ccc; |
| 71 | + border-radius: 0 5px 0 0; |
| 72 | + -webkit-border-radius: 0 5px 0 0; |
| 73 | + -moz-border-radius: 0 5px 0 0; |
| 74 | +} |
| 75 | + |
| 76 | +.tree li:first-child::after { |
| 77 | + border-radius: 5px 0 0 0; |
| 78 | + -webkit-border-radius: 5px 0 0 0; |
| 79 | + -moz-border-radius: 5px 0 0 0; |
| 80 | +} |
| 81 | + |
| 82 | +/*Time to add downward connectors from parents*/ |
| 83 | +.tree ul ul::before { |
| 84 | + content: ''; |
| 85 | + position: absolute; |
| 86 | + top: 0; |
| 87 | + left: 50%; |
| 88 | + border-left: 1px solid #ccc; |
| 89 | + width: 0; |
| 90 | + height: 20px; |
| 91 | +} |
| 92 | + |
| 93 | +.tree li div { |
| 94 | + border: 1px solid #ccc; |
| 95 | + padding: 5px 10px; |
| 96 | + text-decoration: none; |
| 97 | + color: #666; |
| 98 | + font-family: arial, verdana, tahoma; |
| 99 | + font-size: 11px; |
| 100 | + display: inline-block; |
| 101 | + min-width: 80px; |
| 102 | + min-height: 30px; |
| 103 | + border-radius: 5px; |
| 104 | + -webkit-border-radius: 5px; |
| 105 | + -moz-border-radius: 5px; |
| 106 | + transition: all 0.5s; |
| 107 | + -webkit-transition: all 0.5s; |
| 108 | + -moz-transition: all 0.5s; |
| 109 | +} |
| 110 | + |
| 111 | +.tree li div .male { |
| 112 | + background-color: lightblue; |
| 113 | + display: inline-block; |
| 114 | + width: 90px; |
| 115 | + padding: 10px; |
| 116 | + border-radius: 5px; |
| 117 | + -webkit-border-radius: 5px; |
| 118 | + -moz-border-radius: 5px; |
| 119 | +} |
| 120 | + |
| 121 | +.tree li div .female { |
| 122 | + background-color: lightpink; |
| 123 | + display: inline-block; |
| 124 | + width: 90px; |
| 125 | + padding: 10px; |
| 126 | + border-radius: 5px; |
| 127 | + -webkit-border-radius: 5px; |
| 128 | + -moz-border-radius: 5px; |
| 129 | +} |
| 130 | + |
| 131 | +.tree li div .spacer { |
| 132 | + background-color: lightblue; |
| 133 | + display: inline-block; |
| 134 | + width: 10px; |
| 135 | +} |
| 136 | + |
| 137 | +.tree li div.leaf { |
| 138 | + cursor: default; |
| 139 | +} |
| 140 | + |
| 141 | +.tree li div.non-leaf { |
| 142 | + cursor: pointer; |
| 143 | +} |
| 144 | + |
| 145 | +/*Time for some hover effects*/ |
| 146 | +/*We will apply the hover effect to the lineage of the element also*/ |
| 147 | +.tree li div.non-leaf:hover, |
| 148 | +.tree li div.non-leaf:hover + ul li div { |
| 149 | + background: #c8e4f8; |
| 150 | + color: #000; |
| 151 | + border: 1px solid #94a0b4; |
| 152 | +} |
| 153 | + |
| 154 | +/*Connector styles on hover*/ |
| 155 | +.tree li div.non-leaf:hover + ul li::after, |
| 156 | +.tree li div.non-leaf:hover + ul li::before, |
| 157 | +.tree li div.non-leaf:hover + ul::before, |
| 158 | +.tree li div.non-leaf:hover + ul ul::before { |
| 159 | + border-color: #94a0b4; |
| 160 | +} |
0 commit comments