Created
May 1, 2010 08:11
-
-
Save gojomo/386146 to your computer and use it in GitHub Desktop.
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
<head> | |
<style> | |
table.container { | |
width: 522px; | |
border-spacing: 0; | |
border:1px solid gray; | |
} | |
.container td { | |
text-align: center; | |
padding: 0; | |
margin: 0; | |
} | |
.item { | |
background-color:red; | |
height:100px; | |
} | |
</style> | |
</head> | |
<body> | |
↓ table with spacers | |
<table class="container"> | |
<tr> | |
<td class="item" style="width:80px"> </td> | |
<td> </td> | |
<td class="item" style="width:100px"> </td> | |
<td> </td> | |
<td class="item" style="width:80px"> </td> | |
<td> </td> | |
<td class="item" style="width:100px"> </td> | |
<td> </td> | |
<td class="item" style="width:60px"> </td> | |
</tr> | |
</table> | |
<img src="http://blog.directededge.com/wp-content/uploads/2010/04/4.png"><br/> | |
↑ example image from blog of javascript result | |
<p> | |
<p> | |
variable-width example | |
<table class="container" style="width:100%"> | |
<tr> | |
<td class="item" style="width:80px"> </td> | |
<td> </td> | |
<td class="item" style="width:100px"> </td> | |
<td> </td> | |
<td class="item" style="width:80px"> </td> | |
<td> </td> | |
<td class="item" style="width:100px"> </td> | |
<td> </td> | |
<td class="item" style="width:60px"> </td> | |
</tr> | |
</table> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A technque to help with this: http://blog.directededge.com/2010/04/30/the-curious-case-of-equidistant-boxes-a-css-fail/
Takes advantage of a browser's tendency to distribute 'excess' width evenly among TDs with unspecified widths.
Checked on Mac FF3.6, Safari 4.0.3, Chrome 5.0.342.9. That the spacer TDs have non-empty content is important for Safari/Chrome, but not FF.
May break in other compatibility modes...