I'm trying to convert old layout based on tables and JS to the new Flexbox with backward compatibility by keeping the tables for old browsers (specifically IE8, IE9 and Opera 10+).
The problem is that there is no display:flex-item
to override the old style of display:table-cell
.
I've tried various definitions like display:inherit
, display:initial
but none is able to reset the display definition to work correctly as flex-item.
<!-- HTML user list -->
<div class="userDetails layout">
<div class="picture"><img src="..."></div>
<div class="details">username, email, etc.</div>
</div>
/* CSS Table Layout */
.layout { display: table; width: 100%; }
.layout > .picture { display: table-cell; width: 30%; }
.layout > .details { display: table-cell; width: auto; }
/* CSS Flexbox - ignored by browsers that does not support it */
/* just an example - should use all versions for best compatibility */
.layout { display: flex; }
.layout > .picture { display: ???; flex: 0 1 30%; }
.layout > .details { display: ???; flex: 1 1 auto; }
Whatever I set in display for the .details
it does not work as flex-item and does not grow to fill the remaining space.
Any idea how to override this without using JS to detect browser version and switch the styles?
I've tried googling for solution but most of the results are just general articles about Flexbox; only similar is this test which simply does not solve the backward compatility.
UPDATE 1: This is a JSFiddle demo of a pure Flexbox and Flexbox combined with table layout. If you resize the result window, the pure layout shrinks differently than the bottom one that combine table and Flexbox. Note: in Chrome this works correctly, try it in Firefox, IE, Safari, etc.
UPDATE 2: Safari works correctly with prefixed definitions... updated JSFiddle demo