Skip to content

Instantly share code, notes, and snippets.

@ginader
Created July 24, 2012 00:37
Show Gist options
  • Save ginader/3167176 to your computer and use it in GitHub Desktop.
Save ginader/3167176 to your computer and use it in GitHub Desktop.
aligning labels across multiple blocks
/**
* aligning labels across multiple blocks
*/
table {
background:white;
margin:20px;
border:none;
border-spacing: 0;
}
table td,
table th {
background:#EBEBEB;
border: 1px solid #D9D9D9;
padding:2px 10px 4px 10px;
}
table tr:first-child th {
-webkit-border-top-left-radius:10px;
border-top-left-radius:10px;
}
table tr:last-child th {
-webkit-border-bottom-left-radius:10px;
border-bottom-left-radius:10px;
}
table tr:first-child td {
-webkit-border-top-right-radius:10px;
border-top-right-radius:10px;
}
table tr:last-child td {
-webkit-border-bottom-right-radius:10px;
border-bottom-right-radius:10px;
}
table tbody:nth-child(2){
-webkit-transform: translateY(1em);
}
table tbody:nth-child(3){
-webkit-transform: translateY(2em);
}
table tbody:nth-child(4){
-webkit-transform: translateY(3em);
}
table tbody:nth-child(5){
-webkit-transform: translateY(4em);
}
label{
display: block;
text-align: right;
}​
th{
text-align: right;
}
<table>
<tbody>
<tr>
<th><label for="field1">label</label></th>
<td><input type="text" id="field1" value="input"></td>
</tr>
<tr>
<th><label for="field2">label</label></th>
<td><input type="text" id="field2" value="input"></td>
</tr>
</tbody>
<tbody>
<tr>
<th><label for="field3">label bla</label></th>
<td><input type="text" id="field3" value="input"></td>
</tr>
<tr>
<th><label for="field4">label</label></th>
<td><input type="text" id="field4" value="input"></td>
</tr>
</tbody>
<tbody>
<tr>
<th><label for="field5">label bla bla</label></th>
<td><input type="text" id="field5" value="input"></td>
</tr>
<tr>
<th><label for="field6">label</label></th>
<td><input type="text" id="field6" value="input"></td>
</tr>
</tbody>
<tbody>
<tr>
<th>label</th>
<td>blabla</td>
</tr>
<tr>
<th>label</th>
<td>blabla blah</td>
</tr>
</tbody>
<tbody>
<tr>
<th><label for="field9">label</label></th>
<td><input type="text" id="field9" value="input"></td>
</tr>
<tr>
<th><label for="field10">label</label></th>
<td><input type="text" id="field10" value="input"></td>
</tr>
</tbody>
</table>​
{"view":"split-vertical","fontsize":"100","seethrough":"","prefixfree":"1","page":"all"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment