Created
March 21, 2012 00:10
-
-
Save seantimm/2142847 to your computer and use it in GitHub Desktop.
Box Model
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 PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" | |
"http://www.w3.org/TR/html4/loose.dtd"> | |
<html> | |
<head><title>Box Model</title> | |
<link href="style.css" rel="stylesheet" type="text/css"> | |
</head> | |
<body> | |
<div id="box"> | |
<p id="border">BORDER</p> | |
<p id="margin">MARGIN</p> | |
<p id="padding">PADDING</p> | |
<p id="content">CONTENT</p> | |
</div> | |
<!-- Code below is to toggle source and load scripts --> | |
<button id="source">Toggle Source</button> | |
<script type="text/javascript" | |
src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> | |
<script src="script.js" type="text/javascript"></script> | |
<script src="https://gist.github.com/2142847.js" type="text/javascript"></script> | |
</body> | |
</html> |
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
$(function() { | |
// Code to support toggling scripts | |
$("#source").on("click", function(event) { | |
$(".gist").toggle(); | |
}); | |
}); |
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
body, html { | |
padding: 0; | |
margin: 0; | |
} | |
body { | |
font-family: sans-serif; | |
} | |
div#box { | |
position: relative; | |
margin-top: 1em; | |
padding: 1em; | |
border: 1em solid black; | |
background-color: #ffa07a; | |
} | |
p { | |
padding: 0; | |
margin: 0; | |
} | |
p#margin { | |
position: absolute; | |
top: -2em; | |
} | |
p#border { | |
bottom: -1em; | |
color: white; | |
position: absolute; | |
} | |
p#padding { | |
top: 0; | |
position: absolute; | |
} | |
p#content { | |
outline: 5px dotted red; | |
} | |
/* Styles to support toggling the source view */ | |
.gist { | |
font-size: 0.5em; | |
display: none; | |
} | |
div.gist .gist-file { | |
position: relative; | |
margin: 3em 0; | |
} | |
.gist-meta { | |
position: absolute; | |
top: -2.5em; | |
left: -30000px; | |
} | |
.gist-meta a { | |
display: none; | |
} | |
.gist-meta a:nth-child(2) { | |
position: relative; | |
padding-left: 30000px; | |
display: inline; | |
} | |
#source { | |
float: right; | |
} | |
body { | |
font-size: 4em; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment