I think the reason for you is now clear enough, so I'm just going to offer you a workaround to this. Using display:block/inline-block; instead of display:table/table-cell; ,
So the solution is this:
div.container { width: 100%; display: block; } div.container > * { display: inline-block; float:left; } div.middle { width: 100%; max-width: 500px; background-color: black; } div.side { width: auto; background-color: chocolate; }
<div class="container"> <div class="side">Left</div> <div class="middle">.</div> <div class="side">Right</div> </div>
Working: violin
Updated solution:
Found a solution
Returning to the tables would work by specifying table-layout:fixed; into the container .
Working demo
HTML
<div class="container"> <div class="side">Left</div> <div class="middle">.</div> <div class="side">Right</div> </div>
CSS
html, body { width:100%; height:100%; margin:0; padding:0; } .container { display:table; width:100%; height:10px; table-layout:fixed; } .side, .middle { display:table-cell; text-align:center; vertical-align:middle; } .middle { width:500px; background:black; } .side { width : calc(50% - 500px); overflow:hidden; background:chocolate; } @media (max-width: 500px) { .side { display:none; } .middle { width:100%; } }
source share