forked from ahume/selector-queries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.html
169 lines (149 loc) · 5.18 KB
/
demo.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
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Responsive Containers Test Page</title>
<script src="//rawgit.com/ahume/selector-queries/master/src/responsive-containers.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
background-color: #333;
font-family: helvetica, arial, sans-serif;
font-size: 13px;
}
.stage {
background-color: #FFF;
width: 80%;
margin: 0 auto;
overflow: hidden;
padding: 2em 2em 200px 2em;
}
.unit {
float: left;
}
.size1of3 {
width: 33%;
}
.size2of3 {
width: 66%;
}
.menu {
margin: 1em 1em 1em 0;
padding: 0;
}
.menu li {
list-style: none;
margin: 0;
padding: 0;
}
.menu img {
display: none;
}
.menu a:link,
.menu a:visited {
color: #333;
display: block;
text-decoration: none;
border-bottom: 1px solid #AAA;
padding: 0.5em 1em;
}
.menu a:hover,
.menu a:focus,
.menu a:active {
background-color: #CCC;
color: #FFF;
}
.menu li:first-child a {
border-top: 1px solid #AAA;
}
.menu.wide li {
float: left;
list-style: none;
}
.menu.wide img {
display: block;
margin-bottom: 1em;
}
.menu.wide li a {
border: none;
text-align: center;
}
.codex {
color: green;
}
.codex .attr {
color: blue;
}
.meta {
clear: both;
padding-top: 5em;
}
</style>
</head>
<body>
<div class="stage">
<h1>Responsive Containers Test Page</h1>
<p>The two menus below both have identical HTML but are presented differently depending on their current width. At a 'typical' browser width and font size the menu in the smaller column simply lists the links. In the larger column it displays extra images and lays out the options in a grid.</p>
<p>This is achieved with a small piece of JavaScript, which is activated by the code shown below.</p>
<p class="codex"><code><ul class=<span class="attr">"my-list"</span> data-squery=<span class="attr">"min-width:30em=wide"</span>></code></p>
<p>Adding the <code>data-squery</code> attribute above causes a class value of <code>wide</code> to be added to the element when it is wider than 30 ems, and extra CSS is applied to the element based on that class value.</p>
<p>Currently you can use <code>em</code> or <code>px</code> units.</p>
<div class="unit size1of3">
<h2>Menu</h2>
<ul class="menu" data-squery="min-width:30em=wide">
<li>
<a href="#"><img src="http://dummyimage.com/100x100" alt="">
Item 1</a>
</li>
<li>
<a href="#"><img src="http://dummyimage.com/100x100" alt="">
Item 2</a>
</li>
<li>
<a href="#"><img src="http://dummyimage.com/100x100" alt="">
Item 3</a>
</li>
<li>
<a href="#"><img src="http://dummyimage.com/100x100" alt="">
Item 4</a>
</li>
<li>
<a href="#"><img src="http://dummyimage.com/100x100" alt="">
Item 5</a>
</li>
</ul>
</div>
<div class="unit size2of3">
<h2>Menu</h2>
<ul class="menu" data-squery="min-width:30em=wide">
<li>
<a href="#"><img src="http://dummyimage.com/100x100" alt="">
Item 1</a>
</li>
<li>
<a href="#"><img src="http://dummyimage.com/100x100" alt="">
Item 2</a>
</li>
<li>
<a href="#"><img src="http://dummyimage.com/100x100" alt="">
Item 3</a>
</li>
<li>
<a href="#"><img src="http://dummyimage.com/100x100" alt="">
Item 4</a>
</li>
<li>
<a href="#"><img src="http://dummyimage.com/100x100" alt="">
Item 5</a>
</li>
</ul>
</div>
<p class="meta"><small>Find the code: <a href="https://github.com/ahume/selector-queries">https://github.com/ahume/selector-queries</a></small></p>
</div>
<script>
//var els = document.querySelectorAll(".menu");
//SelectorQueries.add(els, "min-width", "30em", "wide");
//SelectorQueries.ignoreDataAttributes();
</script>
</body>
</html>