forked from una/YouMightNotNeedJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
677 lines (638 loc) · 28.4 KB
/
index.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
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
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
<!DOCTYPE html>
<!-- Please edit the index.jade or the files in comparisons/, this file is generated--><!--[if lt IE 10 ]> <html class="old-ie"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Examples of common UI elements and interactions with HTML and CSS alone.">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@una">
<meta name="twitter:creator" content="@una">
<meta name="twitter:title" content="You Might Not Need JavaScript">
<meta name="twitter:description" content="Examples of common UI elements and interactions with HTML and CSS alone.">
<meta name="twitter:image" content="http://youmightnotneedjs.com/shareimg.jpg">
<meta name="og:image" content="http://youmightnotneedjs.com/shareimg.jpg">
<meta name="og:title" content="You Might Not Need JavaScript">
<title>You Might Not Need JavaScript</title>
<link rel="stylesheet" href="css/prism.css">
<link rel="stylesheet" href="css/index.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato">
<script type="text/javascript">
try{Typekit.load();}catch(e){}
</script>
<script src="js/prism.js"></script>
<script src="js/index.js"></script>
<script src="https://assets.codepen.io/assets/embed/ei.js"></script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-36758177-10', 'auto');
ga('send', 'pageview');
</script>
</head>
<body>
<div class="page">
<header class="page-header">
<div class="inner">
<h1>You might <span class="highlighted">no</span>t need <span class="highlighted">JavaScript</span></h1>
</div>
</header>
<div class="explanation">
<div class="inner">
<p>JavaScript is great, and by all means use it, while also being aware that you can build so many functional UI components without the additional dependancy.</p>
<p>
Maybe you can include a few lines of utility code, or a mixin, and forgo the requirement. If you're only targeting more modern browsers,
you might not need anything more than what the browser ships with.
</p>
<p>
This site is fully copied from <a href="http://youmightnotneedjquery.com">youmightnotneedjquery.com</a>, an excellent resource for vanilla JavaScript created by <a href="http://twitter.com/adamfschwartz">@adamfschwartz</a> and <a href="http://twitter.com/zachbloom">@zackbloom</a>.
But this time, we take a look at the power of modern native HTML and CSS as well as some of the syntactic sugar of Sass. Because, you might not need scripts for that task at all! <strong>(Note: these demos may not be accessible. Please take a moment to test them in your project before using in production)</strong>
</p>
</div>
</div>
<div class="share-buttons">
<div class="share-button twitter-share-button">
<iframe src="https://platform.twitter.com/widgets/tweet_button.html?size=l&url=http%3A%2F%2Fyoumightnotneedjs.com&text=You%20might%20not%20need%20JavaScript!" sharecount frameborder="0" scrolling="0" width="90px" title="Tweet button"></iframe>
</div>
<div class="share-button github-stars-button">
<iframe src="https://ghbtns.com/github-btn.html?user=una&repo=YouMightNotNeedJS&type=star&count=true&size=large" frameborder="0" scrolling="0" width="160px" height="30px" title="View on Github"></iframe>
</div>
</div>
<header class="search">
<input type="search" placeholder="Search..." required aria-label="Search">
</header>
<div class="comparisons">
<div class="empty-message">Your search didn't match any comparisons.</div>
<section id="components" class="odd">
<div class="inner">
<h2>Components</h2>
<div id="image_slider" class="comparison">
<h3><a href="#image_slider">Image Slider</a></h3>
<div class="resources-block">
<h4>resources:</h4>
<ul class="resources">
<li><a href=" http://cssslider.com/" target="_blank">CSS Slider Builder</a></li>
<li><a href=" http://xdesigns.net/2013/08/css-slider/" target="_blank">12 CSS Slider Examples</a></li>
<li><a href=" http://benschwarz.github.io/gallery-css/" target="_blank">CSS Gallery</a></li>
</ul>
</div>
<div class="codpen-example">
<h4>CODEPEN</h4><p data-height="265" data-theme-id="light" data-slug-hash="BLxNZq" data-default-tab="result" data-user="una" data-embed-version="2" class="codepen">See the Pen <a href="http://codepen.io/una/pen/BLxNZq/">CSS-Only Slider: youmightnotneedjs.com</a> by Una Kravets (<a href="http://codepen.io/una">@una</a>) on <a href="http://codepen.io">CodePen</a>.</p>
</div>
<div class="comparison-group">
<div data-code="html" class="code html">
<h4>HTML</h4>
<div data-lang="markup" class="code-block language-markup">
<pre><code><div id="slider">
<div id="slide-holder">
<div class="slide">content1</div>
<div class="slide">content2</div>
<div class="slide">content3</div>
</div>
</div>
</code></pre>
</div>
</div>
<div data-code="scss" class="code scss">
<h4>SCSS</h4>
<div data-lang="scss" class="code-block language-scss">
<pre><code>#slider {
width: $slide-width;
height: $slide-height;
overflow: hidden;
}
.slide {
width: $slide-width;
height: $slide-height;
float: left;
position: relative;
}
#slide-holder {
// wide enough to fit all the slides
width: 400%;
position: relative;
left: 0;
will-change: transform;
animation: scroller 10s infinite;
}
// need a step for each slide
@keyframes scroller {
0% { transform: translateX(0); }
33% { transform: translateX(-$slide-width); }
66% { transform: translateX(-$slide-width*2); }
100% { transform: translateX(0); }
}
</code></pre>
</div>
</div>
</div>
<div class="resources-block">
<h4>can i use:</h4>
<ul class="resources">
<li><a href=" http://caniuse.com/#feat=css-animation" target="_blank">CSS Animation</a></li>
<li><a href=" http://caniuse.com/#feat=will-change" target="_blank">Will Change</a></li>
<li><a href=" http://caniuse.com/#feat=transforms2d" target="_blank">Transform</a></li>
</ul>
</div>
</div>
<div id="modal" class="comparison">
<h3><a href="#modal">Modal</a></h3>
<div class="resources-block">
<h4>resources:</h4>
<ul class="resources">
<li><a href=" http://codepen.io/ohnoitsaustin/pen/zGmJjz" target="_blank">Austin Lord's CodePen</a></li>
<li><a href=" http://codepen.io/danielgriffiths/pen/AXGOym" target="_blank">Simple Example by Daniel Griffith</a></li>
</ul>
</div>
<div class="codpen-example">
<h4>CODEPEN</h4><p data-height="265" data-theme-id="light" data-slug-hash="pEVjwj" data-default-tab="result" data-user="una" data-embed-version="2" class="codepen">See the Pen <a href="http://codepen.io/una/pen/pEVjwj/">CSS-Only Modal: youmightnotneedjs.com</a> by Una Kravets (<a href="http://codepen.io/una">@una</a>) on <a href="http://codepen.io">CodePen</a>.</p>
</div>
<div class="comparison-group">
<div data-code="html" class="code html">
<h4>HTML</h4>
<div data-lang="markup" class="code-block language-markup">
<pre><code><button>Click Me</button>
<div class="modal">
<p>Hello Beautiful!</p>
</div>
</code></pre>
</div>
</div>
<div data-code="scss" class="code scss">
<h4>SCSS</h4>
<div data-lang="scss" class="code-block language-scss">
<pre><code>// modal is invisible until
// sibling is focused
.modal {
opacity: 0;
visibility: hidden;
}
// modal fades in when button
// is in focus (i.e. clicked on)
button:focus + .modal {
opacity: 1;
visibility: visible;
}</code></pre>
</div>
</div>
</div>
</div>
<div id="view_switcher" class="comparison">
<h3><a href="#view_switcher">View Switcher</a></h3>
<div class="resources-block">
<h4>resources:</h4>
<ul class="resources">
<li><a href=" http://css3.bradshawenterprises.com/cfimg/" target="_blank">CSS Image Switcher Tutorial</a></li>
<li><a href=" http://codepen.io/tiffanytse/pen/BnDlb" target="_blank">Tiffany Tse CSS Slider</a></li>
</ul>
</div>
<div class="codpen-example">
<h4>CODEPEN</h4><p data-height="265" data-theme-id="light" data-slug-hash="jrxbZq" data-default-tab="result" data-user="una" data-embed-version="2" class="codepen">See the Pen <a href="http://codepen.io/una/pen/jrxbZq/">CSS-Only Image Switcher: youmightnotneedjs.com</a> by Una Kravets (<a href="http://codepen.io/una">@una</a>) on <a href="http://codepen.io">CodePen</a>.</p>
</div>
<div class="comparison-group">
<div data-code="html" class="code html">
<h4>HTML</h4>
<div data-lang="markup" class="code-block language-markup">
<pre><code><div id="slider">
<!-- Slide Images -->
<img id="slide-1" src="img1.jpg" alt="img description"/>
<img id="slide-2" src="img2.jpg" alt="img description"/>
<img id="slide-3" src="img3.jpg" alt="img description"/>
<img id="slide-4" src="img4.jpg" alt="img description"/>
<!-- Navigation for the slides -->
<ul>
<li><a href="#slide-1">1</a></li>
<li><a href="#slide-2">2</a></li>
<li><a href="#slide-3">3</a></li>
<li><a href="#slide-4">4</a></li>
</ul>
</div>
</code></pre>
</div>
</div>
<div data-code="scss" class="code scss">
<h4>SCSS</h4>
<div data-lang="scss" class="code-block language-scss">
<pre><code>#slider {
img {
position: absolute;
top: 0;
left: 0;
width: 300px;
height: 200px;
&:target {
transition: all .5s ease-in-out;
}
&:not(:target),
&:target ~ img#slide-4 {
position: relative;
opacity: 0;
}
// set initially visible
&#slide-4 {
position: absolute;
opacity: 1;
}
}
}</code></pre>
</div>
</div>
</div>
<div class="resources-block">
<h4>can i use:</h4>
<ul class="resources">
<li><a href=" http://caniuse.com/#feat=css-transitions" target="_blank">Transition</a></li>
</ul>
</div>
</div>
</div>
</section>
<section id="forms">
<div class="inner">
<h2>Forms</h2>
<div class="resources-block">
<h4>resources:</h4>
<ul class="resources">
<li><a href=" https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Forms" target="_blank">HTML Form Guide</a></li>
</ul>
</div>
<div id="color_picker" class="comparison">
<h3><a href="#color_picker">Color Picker</a></h3>
<div class="codpen-example">
<h4>CODEPEN</h4><p data-height="160" data-theme-id="light" data-slug-hash="BLxjoo" data-default-tab="result" data-user="una" data-embed-version="2" class="codepen">See the Pen <a href="http://codepen.io/una/pen/BLxjoo/">HTML File Upload: youmightnotneedjs.com</a> by Una Kravets (<a href="http://codepen.io/una">@una</a>) on <a href="http://codepen.io">CodePen</a>.</p>
<script async src="//assets.codepen.io/assets/embed/ei.js"></script>
</div>
<div class="comparison-group">
<div data-code="html" class="code html">
<h4>HTML</h4>
<div data-lang="markup" class="code-block language-markup">
<pre><code><form>
<input type="color" aria-label="Select a color" />
</form>
</code></pre>
</div>
</div>
</div>
<div class="resources-block">
<h4>can i use:</h4>
<ul class="resources">
<li><a href=" http://caniuse.com/#feat=input-color" target="_blank">Color Input Type</a></li>
</ul>
</div>
</div>
<div id="file_upload" class="comparison">
<h3><a href="#file_upload">File Upload</a></h3>
<div class="codpen-example">
<h4>CODEPEN</h4><p data-height="160" data-theme-id="light" data-slug-hash="dpZGPa" data-default-tab="result" data-user="una" data-embed-version="2" class="codepen">See the Pen <a href="http://codepen.io/una/pen/dpZGPa/">HTML File Upload: youmightnotneedjs.com</a> by Una Kravets (<a href="http://codepen.io/una">@una</a>) on <a href="http://codepen.io">CodePen</a>.</p>
</div>
<div class="comparison-group">
<div data-code="html" class="code html">
<h4>HTML</h4>
<div data-lang="markup" class="code-block language-markup">
<pre><code><form>
<input type="file" accept="image/*" aria-label="select file to upload">
<input type="submit">
</form>
</code></pre>
</div>
</div>
</div>
</div>
<div id="form_validation" class="comparison">
<h3><a href="#form_validation">Form Validation</a></h3>
<div class="resources-block">
<h4>resources:</h4>
<ul class="resources">
<li><a href=" https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Forms/Data_form_validation" target="_blank">MDN Data Form Validation</a></li>
<li><a href=" https://codepen.io/SitePoint/pen/Eambf" target="_blank">Phone Number Validation by SitePoint</a></li>
</ul>
</div>
<div class="codpen-example">
<h4>CODEPEN</h4><p data-height="330" data-theme-id="light" data-slug-hash="amGdzK" data-default-tab="result" data-user="una" data-embed-version="2" class="codepen">See the Pen <a href="http://codepen.io/una/pen/amGdzK/">HTML Form Validation: youmightnotneedjs.com</a> by Una Kravets (<a href="http://codepen.io/una">@una</a>) on <a href="http://codepen.io">CodePen</a>.</p>
</div>
<div class="comparison-group">
<div data-code="html" class="code html">
<h4>HTML</h4>
<div data-lang="markup" class="code-block language-markup">
<pre><code><!-- A few examples from links above -->
<form>
<!-- Case insensitive binary choice -->
<label for="item1">Would you prefer a banana or a cherry?</label>
<input id="item1" pattern="[Bb]anana|[Cc]herry">
<!-- Email validation -->
<label for="item2">What's your e-mail?</label>
<input id="item2" type="email" name="email">
<!-- Max length validation -->
<label for="item3">Leave a short message</label>
<textarea id="item3" name="msg" maxlength="140" rows="5"></textarea>
<!-- Numeric + Symbol pattern as required field -->
<label for="item4">Phone Number (format: xxxx-xxx-xxxx):</label><br/>
<input id="item4" type="tel" pattern="^\d{4}-\d{3}-\d{4}$" required >
<button>Submit</button>
</form></code></pre>
</div>
</div>
</div>
<div class="resources-block">
<h4>can i use:</h4>
<ul class="resources">
<li><a href=" http://caniuse.com/#feat=input-pattern" target="_blank">Pattern Attribute</a></li>
</ul>
</div>
</div>
</div>
</section>
<section id="interactions" class="odd">
<div class="inner">
<h2>Interactions</h2>
<div id="scroll_indicator" class="comparison">
<h3><a href="#scroll_indicator">Scroll Indicator</a></h3>
<div class="resources-block">
<h4>resources:</h4>
<ul class="resources">
<li><a href=" http://codepen.io/MadeByMike/pen/ZOrEmr" target="_blank">Example by Mike Riethmuller</a></li>
</ul>
</div>
<div class="codpen-example">
<h4>CODEPEN</h4><p data-height="265" data-theme-id="light" data-slug-hash="bwrEpZ" data-default-tab="result" data-user="una" data-embed-version="2" class="codepen">See the Pen <a href="http://codepen.io/una/pen/bwrEpZ/">CSS Only Scroll Indicator: youmightnotneedjs.com</a> by Una Kravets (<a href="http://codepen.io/una">@una</a>) on <a href="http://codepen.io">CodePen</a>.</p>
</div>
<div class="comparison-group">
<div data-code="html" class="code html">
<h4>HTML</h4>
<div data-lang="markup" class="code-block language-markup">
<pre><code><header class="scroller"></header>
<main>
content must be longer than 100vh
</main></code></pre>
</div>
</div>
<div data-code="scss" class="code scss">
<h4>SCSS</h4>
<div data-lang="scss" class="code-block language-scss">
<pre><code>body {
background: linear-gradient(to right top,
$scroller-color 50%,
$scroller-background 50%);
background-size: 100% calc(100% - 100vh + #{$scroller-height});
background-repeat: no-repeat;
}
body:before {
content:'';
position: fixed;
top: $scroller-height;
bottom: 0;
width: 100%;
z-index: -1;
background: $body-background;
}
</code></pre>
</div>
</div>
</div>
<div class="resources-block">
<h4>can i use:</h4>
<ul class="resources">
<li><a href=" http://caniuse.com/#feat=css-gradients" target="_blank">Linear Gradient</a></li>
<li><a href=" http://caniuse.com/#feat=viewport-units" target="_blank">Viewport Units</a></li>
</ul>
</div>
</div>
</div>
</section>
<section id="navigation">
<div class="inner">
<h2>Navigation</h2>
<div id="accordion" class="comparison">
<h3><a href="#accordion">Accordion</a></h3>
<div class="resources-block">
<h4>resources:</h4>
<ul class="resources">
<li><a href=" http://www.hongkiat.com/blog/css-only-accordion/" target="_blank">4 Ways to Create CSS Accordions</a></li>
<li><a href=" http://codepen.io/oknoblich/pen/tKfab" target="_blank">CodePen Example by Oliver Knoblich</a></li>
</ul>
</div>
<div class="codpen-example">
<h4>CODEPEN</h4><p data-height="310" data-theme-id="light" data-slug-hash="EgLPmZ" data-default-tab="result" data-user="una" data-embed-version="2" class="codepen">See the Pen <a href="http://codepen.io/una/pen/EgLPmZ/">CSS Only Accordion: youmightnotneedjs.com</a> by Una Kravets (<a href="http://codepen.io/una">@una</a>) on <a href="http://codepen.io">CodePen</a>.</p>
</div>
<div class="comparison-group">
<div data-code="html" class="code html">
<h4>HTML</h4>
<div data-lang="markup" class="code-block language-markup">
<pre><code><div class="togglebox">
<input id="toggle1" type="radio" name="toggle" />
<label for="toggle1">Label 1</label>
<section id="content1">
<p>Content for the first accordion</p>
</section>
<input id="toggle2" type="radio" name="toggle" />
<label for="toggle2">Label 2</label>
<section id="content2">
<p>Content for the second accordion</p>
</section>
<input id="toggle3" type="radio" name="toggle" />
<label for="toggle3">Label 3</label>
<section id="content3">
<p>Content for the third accordion</p>
</section>
</div></code></pre>
</div>
</div>
<div data-code="scss" class="code scss">
<h4>SCSS</h4>
<div data-lang="scss" class="code-block language-scss">
<pre><code>// Visually hide radio buttons
input[type="radio"] {
position: absolute;
opacity: 0;
&:focus + label {
color: black;
background-color: wheat;
}
}
// Style label/entry for accordion
label {
position: relative;
display: block;
cursor: pointer;
}
// Style accordion content
section {
height: 0;
transition: .3s all;
overflow: hidden;
}
// Open content when clicking label
#toggle1:checked ~ #content1,
#toggle2:checked ~ #content2,
#toggle3:checked ~ #content3,
#toggle4:checked ~ #content4 {
// set height for transition duration to work
// (also can set to auto without transition)
height: 200px;
}</code></pre>
</div>
</div>
</div>
<div class="resources-block">
<h4>can i use:</h4>
<ul class="resources">
<li><a href=" http://caniuse.com/#feat=css-transitions" target="_blank">Transition</a></li>
</ul>
</div>
</div>
<div id="tabs" class="comparison">
<h3><a href="#tabs">Tabs</a></h3>
<div class="resources-block">
<h4>resources:</h4>
<ul class="resources">
<li><a href=" https://css-tricks.com/functional-css-tabs-re-revisited/" target="_blank">Functional CSS Tabs Revisited</a></li>
<li><a href=" http://codepen.io/mildrenben/pen/bdGdOb" target="_blank">Material Design CSS Tabs</a></li>
</ul>
</div>
<div class="codpen-example">
<h4>CODEPEN</h4><p data-height="265" data-theme-id="light" data-slug-hash="KgRzRE" data-default-tab="result" data-user="una" data-embed-version="2" class="codepen">See the Pen <a href="http://codepen.io/una/pen/KgRzRE/">KgRzRE</a> by Una Kravets (<a href="http://codepen.io/una">@una</a>) on <a href="http://codepen.io">CodePen</a>.</p>
</div>
<div class="comparison-group">
<div data-code="html" class="code html">
<h4>HTML</h4>
<div data-lang="markup" class="code-block language-markup">
<pre><code><div class="tabs">
<div class="tab">
<input type="radio" name="tabgroup" id="tab-1" checked>
<label for="tab-1">Label One</label>
<div class="content">
<p>Tab One Content</p>
</div>
</div>
<div class="tab">
<input type="radio" name="tabgroup" id="tab-2">
<label for="tab-2">Label Two</label>
<div class="content">
<p>Tab Two Content</p>
</div>
</div>
<div class="tab">
<input type="radio" name="tabgroup" id="tab-3">
<label for="tab-3">Label Three</label>
<div class="content">
<p>Tab Three Content</p>
</div>
</div>
</div></code></pre>
</div>
</div>
<div data-code="scss" class="code scss">
<h4>SCSS</h4>
<div data-lang="scss" class="code-block language-scss">
<pre><code>.tabs {
position: relative;
// set height to be even for all tab groups
min-height: 200px;
}
.tab {
float: left;
}
.tab label {
// set label height
top: 1em;
}
// Visually hide radio buttons
.tab [type=radio] {
position: absolute;
height: 0;
width: 0;
overflow: hidden;
clip: rect(0, 0, 0, 0);
&:focus + label {
outline: 2px dotted black;
}
}
.content {
position: absolute;
top: 1em; left: 0; right: 0; bottom: 0;
opacity: 0;
}
[type=radio]:checked ~ label {
z-index: 2;
}
[type=radio]:checked ~ label ~ .content {
z-index: 1;
opacity: 1;
}</code></pre>
</div>
</div>
</div>
</div>
<div id="lightbox" class="comparison">
<h3><a href="#lightbox">Lightbox</a></h3>
<div class="resources-block">
<h4>resources:</h4>
<ul class="resources">
<li><a href=" http://codepen.io/gschier/pen/HCoqh" target="_blank">Gregory Schier's Codepen</a></li>
</ul>
</div>
<div class="codpen-example">
<h4>CODEPEN</h4><p data-height="265" data-theme-id="light" data-slug-hash="wzjGAj" data-default-tab="result" data-user="una" data-embed-version="2" class="codepen">See the Pen <a href="http://codepen.io/una/pen/wzjGAj/">CSS Only Lightbox: youmightnotneedjs.com</a> by Una Kravets (<a href="http://codepen.io/una">@una</a>) on <a href="http://codepen.io">CodePen</a>.</p>
</div>
<div class="comparison-group">
<div data-code="html" class="code html">
<h4>HTML</h4>
<div data-lang="markup" class="code-block language-markup">
<pre><code><!-- thumbnail image wrapped in a link -->
<a href="#img1">
<img src="img.jpg" class="thumbnail">
</a>
<!-- lightbox container hidden with CSS -->
<a href="#" class="lightbox" id="img1">
<img src="img.jpg">
</a></code></pre>
</div>
</div>
<div data-code="scss" class="code scss">
<h4>SCSS</h4>
<div data-lang="scss" class="code-block language-scss">
<pre><code>$thumbnail-size: 40px;
$background-color: black;
.thumbnail {
max-width: $thumbnail-size;
}
.lightbox {
// Hide lightbox image
display: none;
// Position/style of lightbox
position: fixed;
z-index: 999;
width: 100%;
height: 100%;
text-align: center;
top: 0;
left: 0;
background: $background-color;
}
.lightbox img {
/// Pad the lightbox image
max-width: 90%;
max-height: 80%;
margin-top: 2%;
}
.lightbox:target {
// Remove default outline and unhide lightbox
outline: none;
display: block;
}</code></pre>
</div>
</div>
</div>
</div>
</div>
</section>
</div>
<footer>
<p>made by <a href="http://twitter.com/una">@una</a> based on <a href="http://youmightnotneedjquery.com">youmightnotneedjquery.com</a> | contribute on <a href="https://github.com/una/YouMightNotNeedJS">github</a></p>
</footer>
</div>
<div style="-webkit-transform: translateZ(0);"></div>
</body><script>Prism.highlightAll();</script>