this time I try to center one element between other elements. With a table it looks and behaves perfectly like I want it to be. Look at the first blue line in the fiddle (perhaps you need a wider result window to see the right behaviour):
body, div, table, td {
margin: 0;
border: 0;
padding: 0;
}
table, td {
border-collapse: collapse;
}
.settings {
background: blue;
}
.settings input.year{
width: 3em;
}
.settings input.month,
.settings input.day,
.settings input.hour,
.settings input.minute{
width: 1.5em;
}
.settings input.numbers{
width: 2em;
}
.settings p{
color: white;
}
/* version without table */
.settingsWithoutTable {
background: blue;
}
.settingsWithoutTable input.year{
width: 3em;
}
.settingsWithoutTable input.month,
.settingsWithoutTable input.day,
.settingsWithoutTable input.hour,
.settingsWithoutTable input.minute{
width: 1.5em;
}
.settingsWithoutTable input.numbers{
width: 2em;
}
.settingsWithoutTable span{
color: white;
}
<body>
...<br>
<div class="settings"><table><tr>
<td><p>From</p></td>
<td><input class="year" value="2014"/></td>
<td><input class="month" value="04"/></td>
<td><input class="day" value="03"/></td>
<td><input class="hour" value="02"/></td>
<td><input class="minute" value="01"/></td>
<td><button>Frst</button></td>
<td><button>Scnd</button></td>
<td style="width: 50%"></td>
<td><button>Push</button></td>
<td style="width: 50%"></td>
<td><p>Num</p></td>
<td><input class="numbers"></input></td>
</tr></table></div>
...
<div class="settingsWithoutTable">
<span>From</span>
<input class="year" value="2014"/>
<input class="month" value="04"/>
<input class="day" value="03"/>
<input class="hour" value="02"/>
<input class="minute" value="01"/>
<button>Frst</button>
<button>Scnd</button>
<span style="width: 50%"></span>
<button>Push</button>
<span style="width: 50%"></span>
<span>Num</span>
<input class="numbers"></input>
</div>
</body>
Now I heared that tables aren't for layout nowadays and that's why I try to get rid of it. Everything I tried like inline-blocks and so on brings bad results like newlines.
The result should stay in one line and the elements should be aligned like in the table version.
Is there a good way just with css?