There is a bunch of answer on how to set fixed cell sizes here, but I am having trouble finding where in my nested table hierarchy the parameters belong. My table is a visualization of a calendar, with display of possible multiple events. It shows half a year.
My html structure simplified, looks like this:
<table> (whole calendar)
<tr> (whole row of days)
<td> (a single day)
<table> (to be able to display the different data of a single day)
<tr>
<td> (displays the weekday name)
<td> (displays the day of month value)
<td> (cell to hold single or multiple events)
<table> (to be able to split up events inside the <td>)
<tr>
for each event, through jstl:
<td> (display of a single event)
in some cases the event <td> contains both a polygon shape, and text.
The output with to long strings/events looks like this:
Notice the line-break when the polygon and the text extends their given space. I love that they do not expand horizontally, but they should not expand vertically either. it should look like this, only with cut strings if they extend their given space
I have tried to set max-height: on various components, both far up and far down in my hierarchy, but it doesn't seem to have any effect. I have also experimented with table-layout: fixed; but this also makes absolutely no noticable change. As far as I can tell, there are aproximately 8-9 levels in my tables that could be the right place to set the fixed height I am looking for. The highest being the very first tr-level, and the lowest being the td that holds a single event.
- Do I need to declare max-height and/or fixed table-layout on all levels of the hierarchy?
- Are these the right parameters to use?
- Is there a golden rule of precedence when using CSS to style nested tables (or other components)?
I would also welcome any tips on my choice of architecture. I have a feeling there are better ways to do it, but for now, my main goal is to make it work, and hopefully I'll get a little wiser every time.
EDIT: according to the answer to this questions answer, I set the white-space: nowrap; on my top table element, and it worked almost as i wanted it. The cells are staying at their fixed height and width, but a little glitch is that the text continues to be displayed outside of it's to small cell.