/
CSSTree.html
93 lines (88 loc) · 1.83 KB
/
CSSTree.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<html>
<head>
<title>CSS Tree</title>
<style type="text/css">
/* ul[class=tree] and every ul under it loses all alignment, and bullet
* style.
*/
ul.tree, ul.tree ul {
list-style-type: none;
margin:0;
padding:0;
}
/* Every ul under ul[class=tree] gets an indent of 1em, and a background
* image (vertical line) applied to all nodes under it (repeat-y)
*/
ul.tree ul {
padding-left: 1em;
background: url(vline.png) repeat-y;
}
/* ... except the last ul child in every ul; so no vertical lines for
* the children of the last ul
*/
ul.tree ul:last-child {
background: none;
}
/* Every li under ul[class=tree]
* - gets styling to make it bold and blue, and indented.
* - gets a background image (tilted T), to denote that its a node
* - sets height to match the height of background image
*/
ul.tree li {
margin:0;
padding: 0 1.2em;
background: url(node.png) no-repeat;
line-height: 20px;
color: #369;
font-weight: bold;
}
/* The last li gets a different background image to denote it as the
* end of branch
*/
ul.tree li:nth-last-of-type(1) {
background: url(lastnode.png) no-repeat;
}
</style>
</head>
<body>
<a href="http://odyniec.net/articles/turning-lists-into-trees/">Tutorial</a>
<ul class="tree" id="tree">
<li>Animals</li>
<ul>
<li>Birds</li>
<ul>
<li>Parrot</li>
<li>Sparrow</li>
</ul>
<li>Mammals</li>
<ul>
<li>Humans</li>
<li>Cows</li>
</ul>
<li>Fish</li>
<ul>
<li>Salmon</li>
</ul>
<li>Reptiles</li>
<ul>
<li>Snake</li>
<li>Lizard</li>
</ul>
</ul>
<li>Plants</li>
<ul>
<li>Trees</li>
<ul>
<li>Mango</li>
<li>Banyan</li>
<li>Redwood</li>
</ul>
<li>Shrubs</li>
<ul>
<li>Cactus</li>
<li>Congress</li>
</ul>
</ul>
</ul>
</body>
</html>