I have an HTML table that is too wide for small screens. I am trying to get rid of this table and use lists and divs to have a more responsive design.
Here is my HTML I came up with:
<ul> <li class="fixture"> <div class="fixture-date">01/09/2014 20:00</div> <div class="fixture-details"> <div class="home-team">Team A</div> <div class="result">Result</div> <div class="away-team">Team B</div> </div> <ul class="forecasts"> <li class="player-forecast"> <div class="player">Player 1</div> <div class="forecast">Forecast</div> <div class="score">3.0</div> </li> ... </ul> </li> ... </ul>
I want it to look like this on small screens:
---------------------------------------------------- | 01/09/2014 | |----------------------------------------------------| | Team A | Result | Team B | |----------------------------------------------------| | Player 1 | Forecast | 3.0 | |----------------------------------------------------| | Player 2 | Forecast | 0.0 |
and so on on wide screens:
| Player 1 | Player 2 | ------------------------------------------------------------------------------------| | 01/09/2014 | Team A | Result | Team B | Forecast | 3.0 | Forecast | 0.0 | |-----------------------------------------------------------------------------------| | 01/09/2014 | Team C | Result | Team D | Forecast | 1.0 | Forecast | 2.0 |
I installed a script with what I have achieved so far: http://jsfiddle.net/vwanr2gx/
I did not find a way to put all the “cells” for attachment in the same row and keep the same width for the “cells” in the same “column”. I can’t hardcode the cell width for commands, because I don’t know the content (user generated).
I tried to use css tables, but since I have nested divs, it automatically creates new rows (see fiddle).
How can I achieve this (if possible)?
source share