/
index.html
139 lines (122 loc) · 5.29 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
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>responsivepx - find that tricky breakpoint</title>
<!-- Feel free to fork on github too: https://github.com/remy/responsivepx -->
<style>
body { font-family: sans-serif; background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACcAAAAnCAYAAACMo1E1AAAAcUlEQVRYCe3TsQ0AIQzFUGCD7L9jMgIwAJUVOlMiGZ2e/s3M3KPxRETba6vtpQ8P+XEUVTnlqADt3JxyVIB2bk45KkA7N6ccFaDd3PfQ+NVV1esa3flDILYbKaccFaCdm1OOCtDOzSlHBWjn5pSjArQ7Dl0LEgUi4pIAAAAASUVORK5CYII=); margin: 0; padding: 0; }
input { font-size: 16px; padding: 2px; font-family: sans-serif; }
input[type=range] { width: 100px; height: 7px; }
iframe.viewport { position: width: 100%; margin: 34px auto 0 auto; display: block; height: 2000px; -webkit-box-shadow: 0 5px 80px #505050; }
form { height: 30px; overflow: hidden; display: block; background: #333; background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#666666), to(#666666), color-stop(.6,#333)); color: #fff; width: 100%; padding: 2px; position: fixed; top: 0; left: 0; }
form {
text-shadow: 0 -1px 1px #000;
}
#info {
width: 50%;
margin: 15% auto 0;
-webkit-box-shadow: 0 5px 80px #505050;
background: #fff;
padding: 40px;
line-height: 1.4em;
}
#info h1 {
margin-top: 0;
}
#info p:last-child {
margin-bottom: 0;
}
</style>
</head>
<body>
<form>
<input placeholder=http:// value=http:// id=url name=url autocomplete autofocus> <input type=submit value=Open>
<span title="Because I can't determine programatically whether the scrollbars are visible, you need to check this box yourself to adjust the pixel value to give the real viewport width - rather than the window width">Scrollbar visible? <input type=checkbox id=scrollbars checked></span>
Width: <input type=range id=width step=1 min=10 max=3000 value=640><input size=4 type=number step=1 class=width>
Height: <input type=range step=1 id='height' step=10 min=100 max=3000 value=640><input size=4 type=number step=1 class=height>
</form>
<div id="info">
<h1>About responsivepx</h1>
<p>Enter the url to your site - local or online: both work - and use the controls to adjust the width and height of your viewport to find exact breakpoint widths in pixels. Then use that information in your media queries to create a <a href="http://www.alistapart.com/articles/responsive-web-design/">responsive design</a>.</p>
<p>If your site appears with scrollbars, make sure to check the scrollbar visible box to get the right viewport width and height.</p>
<p>Fork the project or log an issue on <a href="http://github.com/remy/responsivepx">github</a></p>
<p>Built by <a href="http://twitter.com/rem">@rem</a></p>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script>
// workout what the dimensions of a scrollbar is for the particular browser.
// It's usually 15px, but who sersiously trusts browsers nowadays?!
function calcScrollbarWidth() {
var el = $('<div style="overflow: scroll;">').appendTo('body')[0];
var offset = el.offsetHeight;
el.parentNode.removeChild(el);
return offset;
}
function newframe(url, scroll) {
$('iframe').remove();
$('<iframe frameborder=0 class="viewport" src="' + url + '"></iframe>').css('display', 'none').appendTo('body').one('load', function () {
// this is just to prevent the initial iframe from appearing empty (as it has a shadow)
$(this).css('display', 'block');
});
}
function size(w, h) {
// ensure the values are numbers
w *= 1;
h *= 1;
// adjust for whether we have the scrollbars visible
if (useoffset) {
w += offset;
h += offset;
}
$('iframe').width(w).height(h);
}
var win = $('iframe'),
$w = $('#width'),
$h = $('#height'),
offset = calcScrollbarWidth(),
useoffset = $('#scrollbars').is(':checked'),
$url = $('#url'),
$hide = $('#hide'),
$range = $('input[type=range]');
$('form').submit(function (e) {
e.preventDefault();
$('#info').remove();
var url = $url.val();
if (url.indexOf('http') !== 0) url = 'http://' + url;
newframe(url, $hide.is(':checked') ? false : true);
$range.trigger('change'); // I realise this triggers the size function twice - I'm just lazy :)
});
$('#scrollbars').click(function () {
useoffset = this.checked;
var w = $('iframe').width() - (useoffset ? offset : 0),
h = $('iframe').height() - (useoffset ? offset : 0);
$('input[type=number], input[type=range]').each(function () {
if (this.id == 'width' || this.className == 'width') {
this.value = w;
} else {
this.value = h;
}
});
});
$('input[type=number]').bind('input', function () {
$('#' + this.className).val(this.value);
size($w.val(), $h.val());
});
$range.bind('change', function () {
$('.' + this.id).val(this.value);
size($w.val(), $h.val());
}).bind('click', function () {
$(this).focus();
});
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-1656750-27']);
_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>
</body>
</html>