-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathbartender.html
More file actions
409 lines (320 loc) · 22.6 KB
/
bartender.html
File metadata and controls
409 lines (320 loc) · 22.6 KB
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="language" content="en" />
<meta name="keywords" content="IOS, tab bar, nav bar, navigation bar, menu, CSS, retina, Jquery Mobile, bartender, plugin, HTML, JQM, cross-browser" />
<meta name="description" content="the bartender-plugin is a CSS-only iOS-style tab bar for mobile and desktop browsers (based on the Jquery Mobile element structure)." />
<meta name="robots" content="index,follow">
<meta name="revisit-after" content="14 days">
<title>Bartender : cross-browser iOS-style tab bar | JQM-based | CSS-only | retina & regular sprite</title>
<!--- <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0b3/jquery.mobile-1.0b3.min.css" /> --->
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0-alpha.1/jquery.mobile-1.2.0-alpha.1.min.css" />
<link rel="stylesheet" type="text/css" href="bartender.css" />
<link rel="canonical" href="http://www.stokkers.mobi/" >
</head>
<body>
<div data-role="page" id="landing">
<div data-role="header" data-position="fixed" data-theme="a">
<h1 class="">Bartender : cross-browser iOS-style tab bar</h1>
</div>
<div data-role="content" class="content">
<h3>Cross-browser iOS-style tab bar</h3>
<p>Since starting to work with Jquery Mobile I have been looking for a more "app-like" navigation bar. There are examples abound, but most can
be used on webkit-browsers only. Since I did not find a real cross-browser solution, I made one myself. I call it the <strong>bartender</strong> plugin.<p>
<h3>Features</h3>
<ul>
<li>based on JQM elements</li>
<li>CSS-only, no Jquery needed</li>
<li>tested on IE7+, latest FF, Opera, Chrome, Safari, Android, iOS</li>
<li>retina icons on all browsers except IE7-8</li>
<li>single retina-regular or separate sprites</li>
<li>All CSS-gradients</li>
</ul>
<p>Below you can find a walkthrough on how to setup the plugin. If you have the icon cut-outs it's pretty much copy & paste.</p>
<p>All files can be found on <a href="https://github.com/frequent/bartender/" title="bartender cross browser iOS tab bar on Github">Github</a>, including icon-background templates and minified CSS.</p>
<div data-role="collapsible-set" class="coll">
<div data-role="collapsible" data-icon="one" data-collapsed="true">
<h3>Quick Guide</h3>
<p>If you are using Jquery Mobile, just copy & paste the CSS and add a class of <span class="typewriter">apple-navbar-ui</span> plus a class of <span class="typewriter">comboSprite</span> (retina-regular combined sprite) or <span class="typewriter">
soloSprite</span> (separate sprites & media query) to the navbar <ul> element. In the CSS change the <span class="typewriter">data-icon="names"</span>
and replace the sprite URL(s) with your own. That's it. If you want to use bartender on a stand-alone basis, make sure your <ul> has the following (JQM-rendered) element structure (you will still need some of
JQM-CSS from both the containing divs):</p>
<pre>
<code>
<div class="ui-footer">
<div>
<ul class="apple-navbar-ui comboSprite">
<li>
<a class="ui-btn">
<span class="ui-btn-inner">
<span class="ui-btn-text"><span class="ui-li-count"></span></span>
<span class="ui-icon"></span>
</span>
</a>
</li>
</ul>
</div>
</div>
</code>
</pre>
<p>As all gradients are CSS-made, you can change the gradient colors to fit your specific page theme. Matching to JQM data-themes is on my Todo list.</p>
</div>
<div data-role="collapsible" data-icon="two" data-collapsed="true">
<h3>Button Backgrounds</h3>
<p>Since I don't think there is a way to stop IE-filters linear-gradients running across an element's full height, <span class="typewriter">ui-icon</span> has to be "wasted" for IE7+8.</p>
<p>Setting the outmost <div>'s background to black and ui-icon height to 50% takes care of IE7+8. The button backgrounds for all other browsers are inserted using pseudo-element
<span class="typewriter">::before</span>, which is placed above .ui-icon and is thankfully ignored by both IE7 (<span class="typewriter">:before</span>) and IE8 (
<span class="typewriter">::before</span>).
</p>
<div class="ui-footer ui-bar-a ui-footer-fixed ui-fixed-inline">
<div class="ui-navbar">
<ul class="apple-navbar-ui ui-grid-d">
<li class="ui-block-a"><a href="#" class=""><span class=""><span class=""></span><span class="ui-icon"></span></span></a></li>
<li class="ui-block-b"><a href="#" class=""><span class=""><span class=""></span><span class="ui-icon"></span></span></a></li>
<li class="ui-block-c"><a href="#" class=""><span class=""><span class=""></span><span class="ui-icon"></span></span></a></li>
<li class="ui-block-d"><a href="#" class=""><span class=""><span class=""></span><span class="ui-icon"></span></span></a></li>
<li class="ui-block-e"><a href="#" class=""><span class=""><span class=""></span><span class="ui-icon"></span></span></a></li>
</ul>
</div>
</div>
<P>I figured this out using <a href="http://nicolasgallagher.com/multiple-backgrounds-and-borders-with-css2/" title="Nicolas Gallagher - Multiple Backgrounds and Borders">Nicolas Gallaghers "Multiple Backgrounds and Borders"</a> article,
which helped me understand how to properly use pseudo-elements <span class="typewriter">::before</span> and <span class="typewriter">::after</span>
as well as <a href="http://7synth.com/dev/gradients" title="Reinhard von der Waydbrink - Linear and Radial Gradients for all Browsers">Reinhard von der Waydbrinks "Linear and Radial Gradients for all Browsers Script"</a>, which I found to be an excellent source on how to get gradients on all browsers - especially IE.
</p>
</div>
<div data-role="collapsible" data-icon="three" data-collapsed="true">
<h3>Icon Backgrounds</h3>
<p>For idle and hover-active state you will need to attach two gradient backgrounds to <span class="typewriter">ui-btn</span>. While the idle gradient is
straightforward, the hover-active background is difficult, as it's using multiple linear and radial background-images, color-stops and transparency. </p>
<p>Too much for IE7+8, who get a plain linear gradient with transparency. All other browser are working smoothly - except for Opera, which supports multiple background-images with linear
gradients only. Once you add a radial gradient the whole background breaks. There is a fallback .png image provided, but since some browsers load this although
not being necessary, the fallback is commented out to not fire an unwanted http-request.
</p>
<div class="ui-footer ui-bar-a ui-footer-fixed ui-fixed-inline">
<div class="ui-navbar">
<ul class="apple-navbar-ui ui-grid-d">
<li class="ui-block-a"><a href="#" class="ui-btn" ><span class=""><span class=""></span><span class="ui-icon"></span></span></a></li>
<li class="ui-block-b"><a href="#" class="ui-btn" ><span class=""><span class=""></span><span class="ui-icon"></span></span></a></li>
<li class="ui-block-c"><a href="#" class="ui-btn" ><span class=""><span class=""></span><span class="ui-icon"></span></span></a></li>
<li class="ui-block-d"><a href="#" class="ui-btn" ><span class=""><span class=""></span><span class="ui-icon"></span></span></a></li>
<li class="ui-block-e"><a href="#" class="ui-btn" ><span class=""><span class=""></span><span class="ui-icon"></span></span></a></li>
</ul>
</div>
</div>
<P>Credits for the gradients go to <a href="http://dribbble.com/shots/66678-iOS-Tab-Bar-Highlight-with-Webkit-CSS-Gradients" title="Jordan Dobson - iOS Tab Bar with Webkit CSS Gradients">Jordan Dobsons iOS Tab Bar with Webkit Gradients</a> for
his excellent walkthrough on how to mimic the iOS active gradient with plain webkit-CSS (I still needed forever for all the other browsers) and to <a href="http://css3please.com/" title="CSS3 Please!">CSS3Please!</a> for showing how to get opacity into IE-filter.
The current gradients aren't perfect. Feel free to chip in and make them closer to the original.
</p>
</div>
<div data-role="collapsible" data-icon="four" data-collapsed="true">
<h3>Button Text and Hover Gradient</h3>
<p>As the Icon background required the <a> <span class="typewriter">ui-btn</span> to be shrunk to 30x30px, the clickable area needs to be reset.
This is done using <span class="typewriter">ui-btn-text</span>, which has to be expanded to full button size and therefore also holds the <span class="typewriter">:hover</span>
gradient. Here you need the only CSS-"Hack", as IE9 renders both the RGBA and MS-filter background resulting in stacked transparent gradients (20%+20% = looks bad). I found
the "Dummy-Hack" solution on <a href="http://stackoverflow.com/questions/6506085/rgba-background-with-ie-filter-alternative-ie9-renders-both " title="IE9 with rgba background and IE filter renders both">Stack Overflow</a>.
</p>
<div class="ui-footer ui-bar-a ui-footer-fixed ui-fixed-inline">
<div class="ui-navbar">
<ul class="apple-navbar-ui ui-grid-d">
<li class="ui-block-a"><a href="#" class="ui-btn" ><span class=""><span class="ui-btn-text">Features</span><span class="ui-icon"></span></span></a></li>
<li class="ui-block-b"><a href="#" class="ui-btn" ><span class=""><span class="ui-btn-text">Brands</span><span class="ui-icon"></span></span></a></li>
<li class="ui-block-c"><a href="#" class="ui-btn" ><span class=""><span class="ui-btn-text">Fees</span><span class="ui-icon"></span></span></a></li>
<li class="ui-block-d"><a href="#" class="ui-btn" ><span class=""><span class="ui-btn-text">Contact</span><span class="ui-icon"></span></span></a></li>
<li class="ui-block-e"><a href="#" class="ui-btn" ><span class=""><span class="ui-btn-text">About</span><span class="ui-icon"></span></span></a></li>
</ul>
</div>
</div>
</div>
<div data-role="collapsible" data-icon="five" data-collapsed="true">
<h3>Icon Sprites</h3>
<p>Unfortunately only webkit supports <span class="typewriter">-webkit-mask-image</span>, so a cross browser solution needs to be set-up differently.
The way to go for me are "cut-out" png-icons (think stamping cookies out of dough and keeping the dough). This works great across all browsers - including IE.</p>
<p>Of course you cannot simply cut-out icons from a plain background, because the icon background needs to match the gradient button background
previously assigned to <span class="typewriter">ui-icon</span>. If you can live with the current button backgrounds simply download the templates from Github and start
cutting your icons. If you make your own button-background, you will also need to redraw the icon-background accordingly.
</p>
<p>To see how it works - for this page, the plain icon background looks like this:</p>
<img src="examples/double300x132.png" alt="sample background template" title="sample background template" />
<p>And the finished cut-out with a background image to show the effect:</p>
<div class="spriteContainer">
<img class="sprite" src="examples/combosprite.png" alt="cut-out sprite" title="cut-out sprite" />
<span class="spriteBack"></span>
</div>
<p>There is also a nice way of putting "retina-icons" on non-retina devices. If you define an element being 30x30px and then specify a background with <span class="typewriter">background-size</span> 60x60px
you are basically loading retina resolution into normal browsers with an artificial 2:1 ratio. Works on all browsers that support the <span class="typewriter">background-size</span>
property, which are all but IE7 and IE8. Zoom in to the following two images to see the difference.
</p>
<div class="spacer">
<div class="hi-res"><span class="spriteText">hi-res</span></div>
<div class="lo-res"><span class="spriteText">lo-res</span></div>
</div>
</div>
<div data-role="collapsible" data-icon="six" data-collapsed="true">
<h3>Combo "retina-regular" or seperate sprites</h3>
<p>You can put both the retina and regular CSS sprite into a single png image. This way you can serve hi-res icons to all browsers except IE7+8, which
get lo-res icons from the same sprite. To do so you need to add a class of <span class="typewriter">comboSprite</span> to the navbar <ul> element.</p>
<p>Alternatively you can use CSS media-queries (like JQM does) to check for retina and then serve the respective sprite. Here you need to add a class of <span class="typewriter">soloSprite</span>.
Both ways are included in the CSS and translate to a single HTTP request, so if you want good cross-browser looks you will have a few KB extra file size.</p>
<p>The icon positioning is also straightforward, although it still needs some tweaking. IE7+8 ignore <span class="typewriter">background-size</span> and render correctly by default.
All other browsers get the artifical ratio and <span class="typewriter">background-position-x/y</span>. IE9+ is still 1px off, any clues on how to get the navbar
to render correctly are welcome.<p>
<p>The sprite is attached to <span class="typewriter">ui-btn-inner</span>. Putting it all together:</p>
<div class="ui-footer ui-bar-a ui-footer-fixed ui-fixed-inline">
<div class="ui-navbar comboSprite">
<ul class="apple-navbar-ui ui-grid-d">
<li class="ui-block-a"><a href="#" data-icon="features" class="ui-btn"><span class="ui-btn-inner"><span class="ui-btn-text">Features</span><span class="ui-icon"></span></span></a></li>
<li class="ui-block-b"><a href="#" data-icon="brands" class="ui-btn"><span class="ui-btn-inner"><span class="ui-btn-text">Brands</span><span class="ui-icon"></span></span></a></li>
<li class="ui-block-c"><a href="#" data-icon="fees" class="ui-btn"><span class="ui-btn-inner"><span class="ui-btn-text">Fees</span><span class="ui-icon"></span></span></a></li>
<li class="ui-block-d"><a href="#" data-icon="contact" class="ui-btn"><span class="ui-btn-inner"><span class="ui-btn-text">Contact</span><span class="ui-icon"></span></span></a></li>
<li class="ui-block-e"><a href="#" data-icon="about" class="ui-btn"><span class="ui-btn-inner"><span class="ui-btn-text">About</span><span class="ui-icon"></span></span></a></li>
</ul>
</div>
</div>
</div>
<div data-role="collapsible" data-icon="six" data-collapsed="true">
<h3>Notifiers and Coming Soon</h3>
<p>You can also use the JQM class of <span class="typewriter">ui-li-count</span> to add count bubbles, which are CSS-ed into notifier icons. The bubbles expand automatically depending on
included text and as the background is a gradient CSS, too, you can tweak the colors according to your desired theme as well.
</p>
<div class="ui-footer ui-bar-a ui-footer-fixed ui-fixed-inline">
<div class="ui-navbar comboSprite">
<ul class="apple-navbar-ui ui-grid-a">
<li class="ui-block-a"><a href="#" data-icon="features" class="ui-btn"><span class="ui-btn-inner"><span class="ui-btn-text">Features<span class="ui-li-count">21</span></span><span class="ui-icon"></span></span></a></li>
<li class="ui-block-b"><a href="#" data-icon="brands" class="ui-btn"><span class="ui-btn-inner"><span class="ui-btn-text">Brands<span class="ui-li-count">!*&%</span></span><span class="ui-icon"></span></span></a></li>
</ul>
</div>
</div>
<p>And there it is, the bartender-plugin.<p>
<p>You can grab the template and sample sprites from <a href="https://github.com/frequent/bartender/" title="bartender cross browser iOS tab bar on Github">Github</a>. I'm planing to add some more features to the plugin (make it scrollable to carry more buttons, look at stick-2-top/left/right,
so make sure to fork the bartender or check back to see how things are coming along. Please post issues, suggestions and such on Github.</p>
</div>
</div>
</div>
<div data-role="footer" data-id="mainFooter" data-position="fixed">
<div data-role="navbar" data-grid="d">
<ul class="apple-navbar-ui comboSprite">
<li><a href="#features" data-iconpos="top" data-icon="features">Features</a></li>
<li><a href="#brands" data-iconpos="top" data-icon="brands">Brands<span class="ui-li-count">10</span></a></li>
<li><a href="#fees" data-iconpos="top" data-icon="fees">Fees</a></li>
<li><a href="#contact" data-iconpos="top" data-icon="contact">Contact</a></li>
<li><a href="#about" data-iconpos="top" data-icon="about">About Us</a></li>
</ul>
</div>
</div>
</div>
<div data-role="page" id="features">
<div data-role="header" data-position="fixed" data-theme="a">
<a href="#landing" data-role="button" data-inline="true">Menu</a>
<h1 class="">Features</h1>
</div>
<div data-role="content" class="content">
<p>This is the <strong>Features</strong> page!</p>
</div>
<div data-role="footer" data-id="mainFooter" data-position="fixed">
<div data-role="navbar" data-grid="d">
<ul class="apple-navbar-ui comboSprite">
<li><a href="#features" class="ui-btn-active ui-state-persist" data-iconpos="top" data-icon="features">Features</a></li>
<li><a href="#brands" data-iconpos="top" data-icon="brands">Brands<span class="ui-li-count">10</span></a></li>
<li><a href="#fees" data-iconpos="top" data-icon="fees">Fees</a></li>
<li><a href="#contact" data-iconpos="top" data-icon="contact">Contact</a></li>
<li><a href="#about" data-iconpos="top" data-icon="about">About Us</a></li>
</ul>
</div>
</div>
</div>
<div data-role="page" id="brands">
<div data-role="header" data-position="fixed" data-theme="a">
<a href="#landing" data-role="button" data-inline="true">Menu</a>
<h1 class="">Brands</h1>
</div>
<div data-role="content" class="content">
<p>This is the <strong>Brands</strong> page!</p>
</div>
<div data-role="footer" data-id="mainFooter" data-position="fixed">
<div data-role="navbar" data-grid="d">
<ul class="apple-navbar-ui comboSprite">
<li><a href="#features" data-iconpos="top" data-icon="features">Features</a></li>
<li><a href="#brands" class="ui-btn-active ui-state-persist" data-iconpos="top" data-icon="brands">Brands<span class="ui-li-count">10</span></a></li>
<li><a href="#fees" data-iconpos="top" data-icon="fees">Fees</a></li>
<li><a href="#contact" data-iconpos="top" data-icon="contact">Contact</a></li>
<li><a href="#about" data-iconpos="top" data-icon="about">About Us</a></li>
</ul>
</div>
</div>
</div>
<div data-role="page" id="fees">
<div data-role="header" data-position="fixed" data-theme="a">
<a href="#landing" data-role="button" data-inline="true">Menu</a>
<h1 class="">Fees</h1>
</div>
<div data-role="content" class="content">
<p>This is the <strong>Fees</strong> page!</p>
</div>
<div data-role="footer" data-id="mainFooter" data-position="fixed">
<div data-role="navbar" data-grid="d">
<ul class="apple-navbar-ui comboSprite">
<li><a href="#features" data-iconpos="top" data-icon="features">Features</a></li>
<li><a href="#brands" data-iconpos="top" data-icon="brands">Brands<span class="ui-li-count">10</span></a></li>
<li><a href="#fees" class="ui-btn-active ui-state-persist" data-iconpos="top" data-icon="fees">Fees</a></li>
<li><a href="#contact" data-iconpos="top" data-icon="contact">Contact</a></li>
<li><a href="#about" data-iconpos="top" data-icon="about">About Us</a></li>
</ul>
</div>
</div>
</div>
<div data-role="page" id="contact">
<div data-role="header" data-position="fixed" data-theme="a">
<a href="#landing" data-role="button" data-inline="true">Menu</a>
<h1 class="">Contact</h1>
</div>
<div data-role="content" class="content">
<p>This is the <strong>Contact</strong> page!</p>
</div>
<div data-role="footer" data-id="mainFooter" data-position="fixed">
<div data-role="navbar" data-grid="d">
<ul class="apple-navbar-ui comboSprite">
<li><a href="#features" data-iconpos="top" data-icon="features">Features</a></li>
<li><a href="#brands" data-iconpos="top" data-icon="brands">Brands<span class="ui-li-count">10</span></a></li>
<li><a href="#fees" data-iconpos="top" data-icon="fees">Fees</a></li>
<li><a href="#contact" class="ui-btn-active ui-state-persist" data-iconpos="top" data-icon="contact">Contact</a></li>
<li><a href="#about" data-iconpos="top" data-icon="about">About Us</a></li>
</ul>
</div>
</div>
</div>
<div data-role="page" id="about">
<div data-role="header" data-position="fixed" data-theme="a">
<a href="#landing" data-role="button" data-inline="true">Menu</a>
<h1 class="">About</h1>
</div>
<div data-role="content" class="content">
<p>This is the <strong>About</strong> page!</p>
</div>
<div data-role="footer" data-id="mainFooter" data-position="fixed">
<div data-role="navbar" data-grid="d">
<ul class="apple-navbar-ui comboSprite">
<li><a href="#features" data-iconpos="top" data-icon="features">Features</a></li>
<li><a href="#brands" data-iconpos="top" data-icon="brands">Brands<span class="ui-li-count">10</span></a></li>
<li><a href="#fees" data-iconpos="top" data-icon="fees">Fees</a></li>
<li><a href="#contact" data-iconpos="top" data-icon="contact">Contact</a></li>
<li><a href="#about" class="ui-btn-active ui-state-persist" data-iconpos="top" data-icon="about">About Us</a></li>
</ul>
</div>
</div>
</div>
</body>
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0-alpha.1/jquery.mobile-1.2.0-alpha.1.min.js"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-19087935-2']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</html>