Loading...

Create family tree (Family Tree) using CSS3

View: 1393    Dowload: 0   Comment: 0   Post by: hanhga   Category: References   Fields: Other

Hi you all, today we continue to learn more in depth about CSS3 by doing a simple example of a tree genealogy (Family Tree). With only the elements of the list (list) we'll reconnect with each other based on the Pseudo element with hover effects. Themselves ensure with you, the article today will be very useful for you.

css3, Family Tree, css3 tips, thu thuat css, css co ban

HTML

Chúng ta sẽ tạo cây gia phả bằng các phần tử html như sau :

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
<!--
 
We will create a family tree using just CSS(3)
 
The markup will be simple nested lists
 
-->
 
<div class="tree">
 
    <ul>
 
        <li>
 
            <a href="#">Parent</a>
 
            <ul>
 
                <li>
 
                    <a href="#">Child</a>
 
                    <ul>
 
                        <li>
 
                            <a href="#">Grand Child</a>
 
                        </li>
 
                    </ul>
 
                </li>
 
                <li>
 
                    <a href="#">Child</a>
 
                    <ul>
 
                        <li><a href="#">Grand Child</a></li>
 
                        <li>
 
                            <a href="#">Grand Child</a>
 
                            <ul>
 
                                <li>
 
                                    <a href="#">Great Grand Child</a>
 
                                </li>
 
                                <li>
 
                                    <a href="#">Great Grand Child</a>
 
                                </li>
 
                                <li>
 
                                    <a href="#">Great Grand Child</a>
 
                                </li>
 
                            </ul>
 
                        </li>
 
                        <li><a href="#">Grand Child</a></li>
 
                    </ul>
 
                </li>
 
            </ul>
 
        </li>
 
    </ul>
 
</div>

CSS

And creating a family tree trees will be created detailing the following:

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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
/*Now the CSS*/
 
* {margin: 0; padding: 0;}
 
 
 
.tree ul {
 
    padding-top: 20px; position: relative;
 
 
 
    transition: all 0.5s;
 
    -webkit-transition: all 0.5s;
 
    -moz-transition: all 0.5s;
 
}
 
 
 
.tree li {
 
    float: left; text-align: center;
 
    list-style-type: none;
 
    position: relative;
 
    padding: 20px 5px 0 5px;
 
 
 
    transition: all 0.5s;
 
    -webkit-transition: all 0.5s;
 
    -moz-transition: all 0.5s;
 
}
 
 
 
/*We will use ::before and ::after to draw the connectors*/
 
 
 
.tree li::before, .tree li::after{
 
    content: '';
 
    position: absolute; top: 0; right: 50%;
 
    border-top: 1px solid #ccc;
 
    width: 50%; height: 20px;
 
}
 
.tree li::after{
 
    right: auto; left: 50%;
 
    border-left: 1px solid #ccc;
 
}
 
 
 
/*We need to remove left-right connectors from elements without
 
any siblings*/
 
.tree li:only-child::after, .tree li:only-child::before {
 
    display: none;
 
}
 
 
 
/*Remove space from the top of single children*/
 
.tree li:only-child{ padding-top: 0;}
 
 
 
/*Remove left connector from first child and
 
right connector from last child*/
 
.tree li:first-child::before, .tree li:last-child::after{
 
    border: 0 none;
 
}
 
/*Adding back the vertical connector to the last nodes*/
 
.tree li:last-child::before{
 
    border-right: 1px solid #ccc;
 
    border-radius: 0 5px 0 0;
 
    -webkit-border-radius: 0 5px 0 0;
 
    -moz-border-radius: 0 5px 0 0;
 
}
 
.tree li:first-child::after{
 
    border-radius: 5px 0 0 0;
 
    -webkit-border-radius: 5px 0 0 0;
 
    -moz-border-radius: 5px 0 0 0;
 
}
 
 
 
/*Time to add downward connectors from parents*/
 
.tree ul ul::before{
 
    content: '';
 
    position: absolute; top: 0; left: 50%;
 
    border-left: 1px solid #ccc;
 
    width: 0; height: 20px;
 
}
 
 
 
.tree li a{
 
    border: 1px solid #ccc;
 
    padding: 5px 10px;
 
    text-decoration: none;
 
    color: #666;
 
    font-family: arial, verdana, tahoma;
 
    font-size: 11px;
 
    display: inline-block;
 
 
 
    border-radius: 5px;
 
    -webkit-border-radius: 5px;
 
    -moz-border-radius: 5px;
 
 
 
    transition: all 0.5s;
 
    -webkit-transition: all 0.5s;
 
    -moz-transition: all 0.5s;
 
}
 
 
 
/*Time for some hover effects*/
 
/*We will apply the hover effect the the lineage of the element also*/
 
.tree li a:hover, .tree li a:hover+ul li a {
 
    background: #c8e4f8; color: #000; border: 1px solid #94a0b4;
 
}
 
/*Connector styles on hover*/
 
.tree li a:hover+ul li::after,
 
.tree li a:hover+ul li::before,
 
.tree li a:hover+ul::before,
 
.tree li a:hover+ul ul::before{
 
    border-color#94a0b4;
 
}

That's all what I want to share to you in the post today, I wish you have more experiences in the process of formation of his career.

Create family tree (Family Tree) using CSS3

Hi you all, today we continue to learn more in depth about CSS3 by doing a simple example of a tree genealogy (Family Tree). With only the elements of the list (list) we'll reconnect with each other based on the Pseudo element with hover effects

Posted on 26-06-2015 

Comment:

To comment you must be logged in members.

Files with category

  • Instructions for installing and configuring Windows Live Mail on Windows 10 simple

    Instructions for installing and configuring Windows Live Mail on Windows 10 simple

    View: 3420    Download: 0   Comment: 0

    Category: References     Fields: Other

    Windows 10 pre-installed Mail application for managing personal email on the device. The latest version of this application but improved a lot and support other email accounts such as Gmail or Yahoo Mail but users almost no "salty" really with this...

  • Step by step instructions to create social networking buttons with CSS3

    Step by step instructions to create social networking buttons with CSS3

    View: 2398    Download: 0   Comment: 0

    Category: References     Fields: Other

    CSS3 help web designers have the ability to create buttons (buttons) very nice, today I will share with you two tips decoration for button in your web becomes radiant beauty that no need to use photoshop.

  • You should understand the CSS Box Shadow

    You should understand the CSS Box Shadow

    View: 2475    Download: 0   Comment: 0

    Category: References     Fields: Other

    Effects his shadow was introduced in the previous article, however, in this article, I will guide more specific about shadow attributes, you try it with anything. First we try to learn css following paragraph:

  • How to do button movement with beautiful CSS3

    How to do button movement with beautiful CSS3

    View: 2149    Download: 0   Comment: 0

    Category: References     Fields: Other

    Previously to create motion effects button, you must draw the button in photoshop, then switched to flash to make it possible to move. But now you need not spend too much time doing it, all because of the emergence of CSS3.

  • Create a dropdown menu with CSS3 effects with beautiful transtions

    Create a dropdown menu with CSS3 effects with beautiful transtions

    View: 2364    Download: 0   Comment: 0

    Category: References     Fields: Other

    More of the dropdown menu you want to introduce to you, this will have the effect menu transitions (converted background of menu background from pale to dark). This menu works well on browsers like FF, Chrome, Safary, but unfortunately did not work...

  • How to hack css for all browsers you should know

    How to hack css for all browsers you should know

    View: 1946    Download: 0   Comment: 0

    Category: References     Fields: Other

    In the process of web design, which makes it the most headaches is how to design web pages that you can run on the browser. Especially when clients use the old as IE6 browser such. However, with this article, you will easily edit interface runs well...

  • Create Accordion with extremely beautiful CSS3

    Create Accordion with extremely beautiful CSS3

    View: 2461    Download: 0   Comment: 0

    Category: References     Fields: Other

    Accordion is a technique that helps you shortened the content that you want displayed on the website. It is often used for the display of submenus. In addition you can also use it for content, images. Before applying this procedure, you have to use...

  • Create the effect Hovercho images with Webkit and CSS3 is great

    Create the effect Hovercho images with Webkit and CSS3 is great

    View: 2079    Download: 0   Comment: 0

    Category: References     Fields: Other

    WebKit is one open source application framework provides the necessary components built one for your web browser. Along with CSS3, cả have contributed to very nice effect những previously only using JavaScript or JQuery thực beige.​

 
File suggestion for you
Loading...
File top downloads
Loading...
Loading...
Codetitle - library source code to share, download the file to the community
Copyright © 2018. All rights reserved. codetitle Develope by Vinagon .Ltd