If you need relative / absolute positioning, there is no cleaner way to specify a different top for n different div s.
Sorry, but you just need to write everything exactly , similar to how you have it. Having done this myself, I think that I have something a little shorter than yours.
For reference, I would do this if I needed positioning:
Live demo
CSS
#roomContainer { position: relative } #roomContainer div { position: absolute; background: #ccc; width: 100px; height: 16px; padding: 10px; text-align: center; outline: 1px solid blue } #room1 { top: 0px } #room2 { top: 40px } #room3 { top: 80px } #room99 { top: 9120px }
HTML:
<div id="roomContainer"> <div id="room1">Room 1</div> <div id="room2">Room 2</div> <div id="room3">Room 3</div> </div>
source share