Created
April 16, 2014 10:04
-
-
Save webin/10845804 to your computer and use it in GitHub Desktop.
2 Column CSS Demo - Equal Height Columns with Cross-Browser CSS
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> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>2 Column CSS Demo - Equal Height Columns with Cross-Browser CSS</title> | |
| <style> | |
| body { | |
| margin:0; | |
| padding:0; | |
| } | |
| #header h1, | |
| #header h2, | |
| #header p { | |
| margin-left:2%; | |
| padding-right:2%; | |
| } | |
| #active2 #tab2, | |
| #active3 #tab3, | |
| #active4 #tab4, | |
| #active5 #tab5 { | |
| font-weight:bold; | |
| text-decoration:none; | |
| color:#000; | |
| } | |
| #footer { | |
| clear:both; | |
| float:left; | |
| width:100%; | |
| } | |
| #footer p { | |
| margin-left:2%; | |
| padding-right:2%; | |
| } | |
| /* Start of Column CSS */ | |
| #container2 { | |
| clear:left; | |
| float:left; | |
| width:100%; | |
| overflow:hidden; | |
| background:#ffa7a7; /* column 2 background colour */ | |
| } | |
| #container1 { | |
| float:left; | |
| width:100%; | |
| position:relative; | |
| right:50%; | |
| background:#fff689; /* column 1 background colour */ | |
| } | |
| #col1 { | |
| float:left; | |
| width:46%; | |
| position:relative; | |
| left:52%; | |
| overflow:hidden; | |
| } | |
| #col2 { | |
| float:left; | |
| width:46%; | |
| position:relative; | |
| left:56%; | |
| overflow:hidden; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div id="header"> | |
| <p><a href="http://matthewjamestaylor.com/blog/equal-height-columns-cross-browser-css-no-hacks" title="Equal Height Columns with Cross-Browser CSS & No Hacks">« Back to the equal height columns article</a> by <a href="http://matthewjamestaylor.com">Matthew James Taylor</a></p> | |
| <h1>Two Column CSS Demo of Equal Height Columns</h1> | |
| <h2>Full Cross-Browser CSS. No CSS Hacks. No Images. No JavaScript.</h2> | |
| </div> | |
| <div id="container2"> | |
| <div id="container1"> | |
| <div id="col1"> | |
| <!-- Column one start --> | |
| <h2>Equal height columns</h2> | |
| <p>It does not matter how much content is in each column, the background colours will always stretch down to the height of the tallest column.</p> | |
| <h2>2 Column Dimensions</h2> | |
| <p>Each column is 50 percent wide with 2 percent padding on each side.</p> | |
| <h2>No CSS hacks</h2> | |
| <p>The CSS used for this 2 column layout is 100% valid and hack free. To overcome Internet Explorer's broken box model, no horizontal padding or margins are used. Instead, this design uses percentage widths and clever relative positioning.</p> | |
| <h2>No Images</h2> | |
| <p>This Two column layout requires no images. Many CSS website designs need images to colour in the column backgrounds but that is not necessary with this design. Why waste bandwidth and precious HTTP requests when you can do everything in pure CSS and HTML?</p> | |
| <h2>No JavaScript</h2> | |
| <p>JavaScript is not required. Some website layouts rely on JavaScript hacks to resize divs and force elements into place but you won't see any of that nonsense here.</p> | |
| <h2>Valid XHTML strict markup</h2> | |
| <p>The HTML in this layout validates as XHTML 1.0 strict.</p> | |
| <!-- Column one end --> | |
| </div> | |
| <div id="col2"> | |
| <!-- Column two start --> | |
| <h2>Cross-Browser Compatible</h2> | |
| <p>This 2 column layout has been tested on the following browsers:</p> | |
| <h3>iPhone & iPod Touch</h3> | |
| <ul> | |
| <li>Safari</li> | |
| </ul> | |
| <h3>Mac</h3> | |
| <ul> | |
| <li>Safari</li> | |
| <li>Firefox</li> | |
| <li>Opera 9</li> | |
| <li>Netscape 7 & 9</li> | |
| </ul> | |
| <h3>Windows</h3> | |
| <ul> | |
| <li>Firefox 1.5, 2 & 3</li> | |
| <li>Safari</li> | |
| <li>Opera 8 & 9</li> | |
| <li>Explorer 5.5, 6 & 7</li> | |
| <li>Google Chrome</li> | |
| <li>Netscape 8</li> | |
| </ul> | |
| <h2>This layout is FREE for anyone to use</h2> | |
| <p>You don't have to pay anything. Simply view the source of this page and save the HTML onto your computer. My only suggestion is to put the CSS into a separate file. If you are feeling generous however, link back to this page so other people can find and use this layout too.</p> | |
| <!-- Column two end --> | |
| </div> | |
| </div> | |
| </div> | |
| <div id="footer"> | |
| <p>This page uses the <a href="http://matthewjamestaylor.com/blog/equal-height-columns-2-column.htm" title="Equal Height Columns with Cross-Browser CSS & No Hacks">Two Equal Height Columns Layout</a> by <a href="http://matthewjamestaylor.com">Matthew James Taylor</a>. View more <a href="http://matthewjamestaylor.com/blog/-website-layouts">website layouts</a>.</p> | |
| </div> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment