I am trying to set the auto width for the left and right divs so that they always snap to the centered div. In my example below, width: 20%; used width: 20%; for the left and right div, which should be dynamic. How can i do this?
I looked at these ( 1 , 2 , 3 ) example for ideas, but could not solve my problem. 3rd is what I want, but it does not work in all browsers.
Feel free to modify the whole code below as I am open to better solutions, but the center of the div should be 850 pixels.
thanks
<style> body { background: #333333; } * { margin: 0; padding: 0; } #cover { float: left; width: 100%; height: 200px; background: #bababa; } #left { float: left; width: 20%; height: 200px; background: #cccccc; } #center { float: left; width: 850px; height: 200px; background: #dddddd; } #right { float: right; width: 20%; height: 200px; background: #eeeeee; } </style> <div id="cover"> <div id="left">LEFT</div> <div id="center">CENTER</div> <div id="right">RIGHT</div> </div>
source share