|
83 | 83 | list-style: none;
|
84 | 84 | padding-left: 0;
|
85 | 85 | margin: 0;
|
| 86 | + justify-content: center; |
86 | 87 | }
|
87 | 88 |
|
88 | 89 | .orgchart .hierarchy {
|
|
100 | 101 | box-sizing: border-box;
|
101 | 102 | }
|
102 | 103 |
|
| 104 | +/* 本姓人与上一层父母的连线,借助伪元素::before实现 */ |
| 105 | +/* 处理同一层中特殊的首节点 */ |
| 106 | +.orgchart .couple:first-child:not(:only-child)::before { |
| 107 | + width: calc(100% - 69px); /* half width of hierarchy - half width of node - node's padding - node's border width */ |
| 108 | + left: 69px; |
| 109 | +} |
| 110 | + |
| 111 | +/* 处理同一层中特殊的末节点 */ |
| 112 | +.orgchart .couple:last-child:not(:only-child)::before { |
| 113 | + width: calc(50% + 71px); |
| 114 | + left: 0px; |
| 115 | +} |
| 116 | + |
| 117 | +.orgchart .hierarchy.couple:only-child::before { |
| 118 | + width: 142px; /* half of node's width + link's width */ |
| 119 | + left: calc(50% - 71px); /* half width of node - half of link width */ |
| 120 | +} |
| 121 | + |
| 122 | +/* 在family tree中,一个夫妻组合里,本姓人只有一个,外姓人可能有多个 */ |
| 123 | +/* 我们通过水平的连线来表示他们存在婚姻关系,借助伪元素::after实现 */ |
| 124 | +.orgchart .hierarchy.spouse:not(.couple)::after { |
| 125 | + content: ""; |
| 126 | + position: absolute; |
| 127 | + border-top: 2px solid rgba(217, 83, 79, 0.8); |
| 128 | + box-sizing: border-box; |
| 129 | + z-index: 0; |
| 130 | + top: 24px; |
| 131 | + width: var(--ft-width); |
| 132 | + left: var(--ft-left-offset); |
| 133 | +} |
| 134 | + |
| 135 | +/* 一夫一妻情况下的连线 */ |
| 136 | +.orgchart .couple { |
| 137 | + white-space: nowrap; |
| 138 | +} |
| 139 | + |
| 140 | +.orgchart .couple:has(> .nodes) > .node:first-child::after { |
| 141 | + content: ""; |
| 142 | + position: absolute; |
| 143 | + top: 24px; |
| 144 | + left: calc(100% + 1px); |
| 145 | + width: 2px; |
| 146 | + height: 33px; |
| 147 | + background-color: rgba(217, 83, 79, 0.8); |
| 148 | +} |
| 149 | +.orgchart .couple::after { |
| 150 | + content: ""; |
| 151 | + position: absolute; |
| 152 | + border-top: 2px solid rgba(217, 83, 79, 0.8); |
| 153 | + box-sizing: border-box; |
| 154 | + z-index: 0; |
| 155 | + top: 24px; |
| 156 | + width: 20px; |
| 157 | + left: calc(50% - 10px); /* half of hierarchy - node's padding width - node's border with */ |
| 158 | +} |
| 159 | + |
103 | 160 | .orgchart .hierarchy:first-child::before,
|
104 | 161 | .orgchart .hierarchy.isSiblingsCollapsed.left-sibs::before {
|
105 | 162 | left: calc(50% - 1px);
|
|
111 | 168 | width: calc(50% + 1px);
|
112 | 169 | }
|
113 | 170 |
|
114 |
| -.orgchart .hierarchy:not(.hidden):only-child::before { |
| 171 | +.orgchart .hierarchy:not(.hidden):not(.spouse):only-child::before { |
115 | 172 | width: 2px;
|
116 | 173 | }
|
117 | 174 |
|
|
122 | 179 | .orgchart .isSiblingsCollapsed.left-sibs:last-child:before,
|
123 | 180 | .orgchart .isCollapsedSibling::before,
|
124 | 181 | .orgchart .isCollapsedSibling .hierarchy::before,
|
125 |
| -.orgchart .isChildrenCollapsed > .node:not(:only-child)::after, |
| 182 | +.orgchart .hierarchy.isChildrenCollapsed:not(.couple) > .node:has(+ .nodes)::after, |
126 | 183 | .orgchart .isCollapsedDescendant::before,
|
127 | 184 | .orgchart .isCollapsedDescendant > .node::before,
|
128 | 185 | .orgchart .isCollapsedDescendant > .node::after,
|
129 | 186 | .orgchart .isAncestorsCollapsed:only-child::before,
|
130 |
| -.orgchart .isAncestorsCollapsed > .node::before { |
| 187 | +.orgchart .isAncestorsCollapsed > .node:not(.outsider)::before { |
131 | 188 | content: none;
|
132 | 189 | }
|
133 | 190 |
|
134 | 191 | /* excluding leaf node */
|
135 |
| -.orgchart .node:not(:only-child)::after { |
| 192 | +.orgchart .hierarchy:not(.couple) > .node:has(+ .nodes)::after { |
136 | 193 | content: "";
|
137 | 194 | position: absolute;
|
138 | 195 | bottom: -12px; /* -(background square size + node's border width) */
|
|
155 | 212 | background-color: rgba(238, 217, 54, 0.5);
|
156 | 213 | }
|
157 | 214 | /* excluding root node */
|
158 |
| -.orgchart > ul > li > ul li > .node::before { |
| 215 | +.orgchart > ul > li > ul li > .node:not(.outsider)::before { |
159 | 216 | content: "";
|
160 | 217 | position: absolute;
|
161 | 218 | top: var(--top, -12px); /* -(fallback value = background square size + border width of node) */
|
|
165 | 222 | background-color: rgba(217, 83, 79, 0.8);
|
166 | 223 | }
|
167 | 224 |
|
168 |
| -.orgchart > ul > li > ul li.isSiblingsCollapsed > .node::before { |
| 225 | +.orgchart > ul > li > ul li > .node.outsider::before { |
| 226 | + content: ""; |
| 227 | + position: absolute; |
| 228 | + top: var(--top, -12px); |
| 229 | + left: calc(50% - 1px); |
| 230 | + width: 0; |
| 231 | + height: var(--height, 10px); |
| 232 | + border-right: 2px dotted rgba(217, 83, 79, 0.8); |
| 233 | +} |
| 234 | + |
| 235 | +.orgchart > ul > li > ul .isSiblingsCollapsed > .node::before { |
169 | 236 | top: var(--top-cross-point, -12px);
|
170 | 237 | height: var(--height-cross-point, 10px);
|
171 | 238 | }
|
|
179 | 246 | padding: 3px;
|
180 | 247 | border: 2px dashed transparent;
|
181 | 248 | text-align: center;
|
| 249 | + transition: transform 0.3s, opacity 0.3s; |
| 250 | + z-index: 1; |
182 | 251 | }
|
183 | 252 |
|
184 | 253 | .orgchart.l2r .node, .orgchart.r2l .node {
|
|
190 | 259 | background-color: rgba(238, 217, 54, 0.5);
|
191 | 260 | transition: .5s;
|
192 | 261 | cursor: default;
|
193 |
| - z-index: 20; |
| 262 | + z-index: 2; |
194 | 263 | }
|
195 | 264 |
|
196 | 265 | .orgchart .node.focused {
|
|
420 | 489 | padding: 0.5rem 1rem;
|
421 | 490 | }
|
422 | 491 |
|
423 |
| -.orgchart .node { |
424 |
| - transition: transform 0.3s, opacity 0.3s; |
425 |
| -} |
426 |
| - |
427 | 492 | .orgchart .slide-down {
|
428 | 493 | opacity: 0;
|
429 | 494 | transform: translateY(40px);
|
|
479 | 544 | margin-bottom: 0;
|
480 | 545 | }
|
481 | 546 |
|
482 |
| -.orgchart .nodes.vertical .node::before, |
483 |
| -.orgchart .nodes.vertical .node::after { |
| 547 | +.orgchart .nodes.vertical .hierarchy .node::before, |
| 548 | +.orgchart .nodes.vertical .hierarchy .node::after { |
484 | 549 | content: none;
|
485 | 550 | }
|
486 | 551 |
|
|
500 | 565 | border-width: 0 0 2px 2px;
|
501 | 566 | }
|
502 | 567 |
|
| 568 | +.orgchart .nodes.vertical .hierarchy:only-child::before { |
| 569 | + width: 11px; |
| 570 | +} |
| 571 | + |
503 | 572 | .orgchart .nodes.vertical .hierarchy::before {
|
504 | 573 | top: 0px;
|
505 | 574 | height: 26px; /* node top half's height(25px) + half width of line */
|
|
627 | 696 | margin-bottom: 0;
|
628 | 697 | }
|
629 | 698 |
|
630 |
| -.orgchart .node.compact .node:not(:only-child)::after { |
| 699 | +.orgchart .node.compact .node:has(+ .nodes)::after { |
631 | 700 | content: unset;
|
632 | 701 | }
|
633 | 702 |
|
|
0 commit comments