I am trying to create my own calendar in HTML and Javascript where you can drag and drop tasks from one day to another. I would like to have the first column and the last two columns as a fixed width and have the remaining columns (Monday through Friday) so that the table always fills 100% of this parent.
The problem I am facing is that liquid TD automatically evaluates itself based on the amount of content in them, which means that when you drag tasks from one day to another, the column widths change. I would like it to be exactly the same size from Monday to Friday, regardless of content and without setting text overflow: hidden; (since tasks should always be visible)
i.e. I want the gray columns to be fixed in width and the red columns to be flowing but uniform from each other, regardless of the content inside them.
Edit: I am using jQuery for the drag and drop function, so the JavaScript solution will also be fine (although not preferable).
JSFiddle Live Example
HTML:
<table> <tr> <th class="row_header">Row Header</th> <th class="fluid">Mon</th> <th class="fluid">Tue</th> <th class="fluid">Wed</th> <th class="fluid">Thurs</th> <th class="fluid">Fri</th> <th class="weekend">Sat</th> <th class="weekend">Sun</th> </tr> <tr> <td>Before Lunch</td> <td>This col will be wider than the others because it has lots of content...</td> <td></td> <td></td> <td></td> <td>But I would really like them to always be the same size!</td> <td></td> <td></td> </tr> </table>
CSS
table { width: 100%; } td, th { border:1px solid black; } th { font-weight:bold; background:red; } .row_header { width:50px; background:#ccc; } .weekend { width:100px; background:#ccc; } .fluid { ??? }
html css html-table fluid
Danny
source share