-
Notifications
You must be signed in to change notification settings - Fork 707
/
Copy pathflex-order-example.html
72 lines (70 loc) · 1.54 KB
/
flex-order-example.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
<!DOCTYPE html>
<title>test</title>
<ul class=tabs>
<li>one</li>
<li>two</li>
<li class=current>three</li>
<li>four</li>
</ul>
<div class=cards>
<div>I am the content connected to the first tab.</div>
<div>I am the content connected to the second tab.</div>
<div class=current>I am the content connected to the third tab.</div>
<div>I am the content connected to the fourth tab.</div>
</div>
<style>
.tabs {
display: -moz-box;
display: -webkit-box;
display: -webkit-flexbox;
display: flexbox;
padding: 0 0 0 2px;
margin: 1em 0 0;
}
.tabs > li {
display: block;
background: white;
color: gray;
padding: 2px 5px 0;
margin: 0 1px;
border-radius: .5em .5em 0 0;
border: 2px solid;
border-bottom: none;
cursor: pointer;
}
.tabs > li.current {
color: black;
border-bottom: 2px solid transparent;
position: relative;
bottom: -2px;
-moz-box-ordinal-group: 0;
-webkit-box-ordinal-group: 0;
-webkit-flex-order: -1;
flex-order: -1;
}
.cards {
border: 2px solid;
width: 500px;
}
.cards > * {
min-height: 50px;
padding: 1em;
}
.cards > :not(.current) {
display: none;
}
</style>
<script>
function find(sel) { return document.querySelector(sel); }
function findAll(sel) { return [].slice.call(document.querySelectorAll(sel)); }
var tabs = findAll('.tabs > *');
var cards = findAll('.cards > *');
tabs.forEach(function(el) {
el.onclick = function(e) {
findAll('.current').forEach(function(el) { el.classList.remove('current'); });
el.classList.add('current');
var index = tabs.indexOf(el);
cards[index].classList.add('current');
};
});
</script>