Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Is this helpful? </p> <p><a href="http://jsfiddle.net/dtCPe/" rel="nofollow noreferrer">CSS Only Demo</a></p> <p><a href="http://jsfiddle.net/msvkL/" rel="nofollow noreferrer">jQuery Demo(Cross Browser Compatible)</a></p> <pre><code>&lt;div class="wrap"&gt; &lt;div id="pixelLeft"&gt;&amp;nbsp;&lt;/div&gt; &lt;div id="bannerCenter"&gt; &lt;img src="images/mybanner.png" /&gt; &lt;/div&gt; &lt;div id="pixelRight"&gt;&amp;nbsp;&lt;/div&gt; &lt;/div&gt; &lt;div style="clear:both;"&gt;&lt;/div&gt; *{ margin:0; padding:0; } #bannerCenter{ background:#ddd; width: 500px; float:left; } #pixelLeft{ background:#999; width: calc(50% - 250px); float:left; } #pixelRight{ background:#999; width: calc(50% - 250px); float:right; } #bannerCenter,#pixelLeft,#pixelRight{ height: 400px; } </code></pre> <p>You can use jQuery instead of using <code>calc(50% - 250px);</code> to make it compatible for older browsers.</p> <pre><code>$(document).ready(function() { $(window).on('resize', function() { $('#pixelLeft, #pixelRight').css('width',($('body').width()-$('#bannerCenter').width())/2); }).trigger('resize'); }); </code></pre> <h1>Update: June 2018</h1> <p>Added flexbox solution for same problem.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>*{ margin:0; padding:0; } .wrap { display: flex; } #pixelLeft, #pixelRight{ display: flex; flex:1; } #bannerCenter{ background:#ddd; min-width: 500px; display: flex; flex: 1; } #pixelLeft{ background:#999; } #pixelRight{ background:#999; } #bannerCenter,#pixelLeft,#pixelRight{ height: 400px; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="wrap"&gt; &lt;div id="pixelLeft"&gt;&amp;nbsp;&lt;/div&gt; &lt;div id="bannerCenter"&gt; &lt;img src="images/mybanner.png" /&gt; &lt;/div&gt; &lt;div id="pixelRight"&gt;&amp;nbsp;&lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload