I have a problem with my display:table based layout. I’d like the table-row containing the select to extend to fill the width of its parent table but, as evidenced by the background and border, this isn’t happening and I have no idea why not!
The problem is that you have one cell for the select but in the same table structure you have two cells in the next row (table centre) which can’t be resolved as there is no colspan in css tables.
You would need to do the select section as a separate one row table rather than a table with 2 rows.
However I think you may need to re-think a little as you do not want to build the whole site trying to mimic tables unless you need that rigid linear alignment that tables offfer.
Use css tables to create equal column sections where needed but don’t overdo it. It may be that you do need your nested table approach but take care with it.
I would also suggest that in this case you let your class names reflect the table property you are using so that you can easily see where you have missed something in a complicated table structure. I know its non-semantic but I’ve done this thousands of times now and it simply works best for css tables.
Many thanks for that. I made the changes to my code however I also noticed another problem.
If (as happens in my ui) the ‘.centre’ div is hidden (when nothing is selected in the ‘.centreSelection’ div - actually a table in the full version), the ‘.centreSelection’ div fills in 100 width despite being set to 100px. Any way to enforce the 100px?
A row of table-cells matches the width of their parent table.
In case there is only one table-cell, it still does the same thing regardless of any cell width that you try to impose.
You can change the width of that table to 100px instead of 100%; The cell will follow.
Or you could change the table-cell, .centreSelection, to display:block; so it’s not a table-cell any more.
Yes but if I were to change the .centreSelection to a display:block, the adjacent .centre when unhidden would need a specific width which is a problem given the auto margins on the root.
Sigh. I’m going to have to go back to using floats aren’t I?
Help me understand the dynamics of that portion of your page. .centre is hidden as in {visibility:hidden} or {display:none}? Under what conditions is it made visible? Does anything happen to .centreSelection when .centre becomes visible?
.centre is hidden by simply not being there initially (dictated by the web platform we use). When a user selects a centre from the table in .centreSelection, then centre is added via ajax. Nothing happens to .centreSelection when a .centre becomes visible.
Ok, that’s vague enough. Can you simulate the content that is expected to be in the .centreSelection and the size of the content that is in .centre? I’m looking for relative sizes and how they flow since they seem to be on the same line in your demo.
.centreSelection contains a div containing a number of filters (selects and inputs) under which there is a table with a few columns. .centre simply contains a list of properties displayed as a definition list with inline dt & dds. .centreSelection has a fixed height and width whereas .centre is supposed to take up all the remaining horizontal space and as much height as needed to accommodate its content (although currently they’re both pretty much the same height).
I’ll flesh out the JSFiddle when I have a bit more time.
Just for fun (and in the absence of more information)… I deleted a few unnecessary table properties and their divs. The result is considerably less CSS and 4 fewer <div>s. I think you will still feel pretty much at home with the code. And it IS IE8 compatible.
I added an “ajaxbox” where your imported definition list items can be placed. The box can be deleted without upsetting the layout. There are no fixed heights.
One easy way to get an overview of the layout is to enable to magenta TEST Outline around the table-cells. You can add other outlines if you wish without affecting the layout of the page.
This is a “working page”. Copy it to a file, give it an .html suffix and open it in your browser to give it the “try before you buy” test.