Created
January 17, 2012 13:35
-
-
Save jakejscott/1626646 to your computer and use it in GitHub Desktop.
940px wide 4 column grid using negative margins
This file contains hidden or 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 XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
| <html xmlns="http://www.w3.org/1999/xhtml"> | |
| <head> | |
| <title></title> | |
| </head> | |
| <body> | |
| <div id="wrapper"> | |
| <div class="clearfix"> | |
| Before Grid | |
| </div> | |
| <div class="grid"> | |
| <div class="row clearfix"> | |
| <div class="col">col 1</div> | |
| <div class="col">col 2</div> | |
| <div class="col">col 3</div> | |
| <div class="col">col 4</div> | |
| </div> | |
| <div class="row clearfix"> | |
| <div class="col">col 1</div> | |
| <div class="col">col 2</div> | |
| <div class="col">col 3</div> | |
| <div class="col">col 4</div> | |
| </div> | |
| </div> | |
| <div class="clearfix"> | |
| After Grid | |
| </div> | |
| </div> | |
| <style> | |
| html, body { | |
| margin: 0; | |
| padding: 0; | |
| height: 100%; | |
| width: 100%; | |
| } | |
| #wrapper { | |
| width: 940px; | |
| background: #ccc; | |
| margin: 0 auto; | |
| } | |
| .grid { | |
| float: left; | |
| margin-left: 20px; | |
| } | |
| .row { | |
| width: 960px; | |
| margin-left: -20px; | |
| } | |
| .col { | |
| margin-right: 20px; | |
| width: 220px; | |
| float: left; | |
| background: orangered; | |
| } | |
| .clearfix:before, .clearfix:after { content: ""; display: table; } | |
| .clearfix:after { clear: both; } | |
| .clearfix { zoom: 1; } | |
| </style> | |
| </body> | |
| </html> |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Help from this: http://csswizardry.com/2011/08/building-better-grid-systems/