Skip to content

Instantly share code, notes, and snippets.

@alexch
Forked from nfiniteset/index.html
Created August 26, 2011 01:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexch/1172436 to your computer and use it in GitHub Desktop.
Save alexch/1172436 to your computer and use it in GitHub Desktop.
Pages that scale to fit window size
<!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