Created
February 9, 2012 03:44
-
-
Save alixaxel/1777103 to your computer and use it in GitHub Desktop.
styleshit - Responsive Preview
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>styleshit 1.0</title> | |
<style type="text/css"> | |
iframe { | |
border: none; | |
} | |
iframe::-webkit-scrollbar { | |
display: none; | |
} | |
body > input#url { | |
font: x-large/2em Arial, Helvetica, sans-serif; | |
display: block; | |
width: 80%; | |
margin: 1em auto; | |
text-align: center; | |
} | |
</style> | |
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script> | |
<script type="text/javascript"> | |
$(function() { | |
$('#url').keypress(function(e) { | |
if ((e.which == 13) && ($('#url').val().length > 0)) { | |
var devices = { | |
'iPhone': [320, 480], | |
'iPhone (Landscape)': [480, 320], | |
'Facebook Page Tab': [520, 520], | |
'Kindle Fire': [600, 1024], | |
'iPad': [768, 1024], | |
'SVGA': [800, 600], | |
'Kindle Fire (Landscape)': [1024, 600], | |
'iPad (Landscape)': [1024, 768], | |
'HD 720p': [1280, 720], | |
'13" MacBook Air': [1440, 900], | |
'WSXGA+': [1680, 1050], | |
}; | |
$('body > div').remove(); | |
$.each(devices, function(device, viewport) { | |
var frame = $('<div></div>').attr({ | |
'style': [ | |
'background: #111;', | |
'border-radius: 8px;', | |
'box-shadow: 0 0 16px rgba(0, 0, 0, 0.5);', | |
'margin: 32px auto;', | |
'max-width: 95%;', | |
'padding: 0 16px 16px 16px;', | |
'width: ' + viewport[0] + 'px;', | |
].join(' '), | |
}).append( | |
$('<h3></h3>').attr({ | |
'style': [ | |
'color: white;', | |
'text-align: center;', | |
'font: bold small/3.5em Arial, sans-serif;', | |
'margin: 0;' | |
].join(' '), | |
}).text(device + ' (' + viewport[0] + 'x' + viewport[1] + ')') | |
).append( | |
$('<iframe></iframe>').attr({ | |
'sandbox': 'allow-forms allow-same-origin allow-scripts allow-top-navigation', | |
'src': $('#url').val(), | |
'style': [ | |
'background: white;', | |
'box-shadow: 0 0 5px rgba(255,255,255,.3);', | |
'height: ' + viewport[1] + 'px;', | |
'width: 100%;', | |
].join(' '), | |
}) | |
); | |
$('body').append(frame); | |
$('iframe:last').load(function () { | |
}); | |
}); | |
} | |
}); | |
$('body').attr({ | |
'style': [ | |
'margin: 0;', | |
'background: -webkit-radial-gradient(black 15%, transparent 16%) 0 0, -webkit-radial-gradient(black 15%, transparent 16%) 8px 8px, -webkit-radial-gradient(rgba(255,255,255,.1) 15%, transparent 20%) 0 1px, -webkit-radial-gradient(rgba(255,255,255,.1) 15%, transparent 20%) 8px 9px;', | |
'background-color: #282828;', | |
'background-size: 16px 16px;', | |
].join(' '), | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<input id="url" placeholder="type any URL and hit enter" /> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment