SHOW:
|
|
- or go back to the newest paste.
| 1 | <!doctype html> | |
| 2 | - | <html lang="en" class="no-js responsive"> |
| 2 | + | <html lang="en" class="no-js"> |
| 3 | <head> | |
| 4 | <meta charset="utf-8"> | |
| 5 | <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"> | |
| 6 | <style type="text/css"> | |
| 7 | .content { margin: 0 auto; }
| |
| 8 | .responsive .content{ background:yellow; width: 70% }
| |
| 9 | .responsive .fixed-width-link { display: block; }
| |
| 10 | .responsive .responsive-link { display: none; }
| |
| 11 | .fixed-width .content { background:red; width: 600px; }
| |
| 12 | .fixed-width .fixed-width-link { display: none; }
| |
| 13 | .fixed-width .responsive-link { display: block; }
| |
| 14 | </style> | |
| 15 | </head> | |
| 16 | - | <body class=""> |
| 16 | + | <body class="responsive"> |
| 17 | <script type="text/javascript"> | |
| 18 | (function(doc, classToAdd){
| |
| 19 | doc.className = (doc.className).replace("no-js", classToAdd);
| |
| 20 | })(document.documentElement, "js"); | |
| 21 | function FixedWidth() {
| |
| 22 | - | if (window.location.hash == "#fixed-width") {
|
| 22 | + | (function(body, classToAdd) {
|
| 23 | - | (function(doc, classToAdd) {
|
| 23 | + | body.className = (body.className).replace("responsive", classToAdd);
|
| 24 | - | doc.className = (doc.className).replace("responsive", classToAdd);
|
| 24 | + | })(document.body, "fixed-width"); |
| 25 | - | })(document.documentElement, "fixed-width"); |
| 25 | + | viewport = document.querySelector("meta[name=viewport]");
|
| 26 | - | viewport = document.querySelector("meta[name=viewport]");
|
| 26 | + | viewport.setAttribute('content', 'width=device-width, user-scalable=yes, initial-scale=1.0');
|
| 27 | - | viewport.setAttribute('content', 'width=device-width, user-scalable=yes, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0');
|
| 27 | + | |
| 28 | - | } |
| 28 | + | |
| 29 | (function(body, classToAdd) {
| |
| 30 | body.className = (body.className).replace("fixed-width", classToAdd);
| |
| 31 | - | if (window.location.hash == "#responsive") {
|
| 31 | + | })(document.body, "responsive"); |
| 32 | - | (function(doc, classToAdd) {
|
| 32 | + | viewport = document.querySelector("meta[name=viewport]");
|
| 33 | - | doc.className = (doc.className).replace("fixed-width", classToAdd);
|
| 33 | + | viewport.setAttribute('content', 'width=device-width, user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0');
|
| 34 | - | })(document.documentElement, "responsive"); |
| 34 | + | |
| 35 | - | viewport = document.querySelector("meta[name=viewport]");
|
| 35 | + | |
| 36 | - | viewport.setAttribute('content', 'width=device-width, user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0');
|
| 36 | + | |
| 37 | - | } |
| 37 | + | |
| 38 | <div class="content"> | |
| 39 | <h1 class="fixed-width-link">Responsive</h1> | |
| 40 | <h1 class="responsive-link">Fixed Width</h1> | |
| 41 | <a href="#" onclick="return FixedWidth()" class="fixed-width-link">Fixed Width</a> | |
| 42 | <a href="#" onclick="return Responsive()" class="responsive-link">Reponsive</a> | |
| 43 | </div> | |
| 44 | </body> | |
| 45 | - | <a href="#fixed-width" onclick="return FixedWidth()" class="fixed-width-link">Fixed Width</a> |
| 45 | + |