Created
August 26, 2011 00:31
-
-
Save nfiniteset/1172396 to your computer and use it in GitHub Desktop.
Pages that scale to fit window size
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> | |
<title>Scaling preso</title> | |
<style> | |
html { | |
font-size: 7.68px | |
} | |
body { | |
margin: 0; | |
padding: 0; | |
} | |
.slide { | |
width: 129rem; // 133rem - 10rem padding - 4rem margin; | |
height: 86rem; // 100rem - 10rem padding - 4rem margin; | |
margin: 2rem auto; | |
padding: 5rem; | |
background-color: #ccc; | |
color: #333; | |
font-family: helvetica, arial, sans-serif; | |
line-height: 14rem; | |
} | |
h1 { | |
font-size: 20rem; | |
line-height: 28rem; | |
margin: 0 0 7rem 0; | |
border-bottom: 1rem solid #bbb; | |
} | |
p { | |
font-size: 12rem; | |
margin: 0 0 | |
} | |
</style> | |
</head> | |
<body> | |
<div class="slide"> | |
<h1>Hello, world!</h1> | |
<p>Wouldn't it be rad <br/>if your preso scaled <br/>to fit your display?</p> | |
</div> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script> | |
<script> | |
var $html = $('html'); | |
$(document).ready(function(){ | |
calibrateScale(); | |
}); | |
$(window).resize(function(){ | |
calibrateScale(); | |
}) | |
function calibrateScale() { | |
$html.css('font-size', $(window).height()/100); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment