Note that there are some explanatory texts on larger screens.

plurals
  1. PODynamic element width and IE9 subpixel precision
    primarykey
    data
    text
    <p>I have 3 divs, #left, #center and #right that I want to position on the same line which has a specific width, say 300px.</p> <p>#left and #right have little content, say 50px each, and I am displaying them fully.</p> <p>#center has a lot of content, say 400px, and I want to display as much as possible within the remaining space on the line. For this, I have included the content of #center within #inner.</p> <p>I have floated #left and #center to left and #right to right.</p> <pre><code>&lt;div id="left"&gt; LEFT &lt;/div&gt; &lt;div id="center"&gt; &lt;div id="inner"&gt; LONG CONTENT ... &lt;/div&gt; &lt;/div&gt; &lt;div id="right"&gt; RIGHT &lt;/div&gt; </code></pre> <p><a href="http://jsfiddle.net/R7nJU/4/" rel="nofollow">Example fiddle</a></p> <p>Question 1: Is there a way of making the #center div take all of the available remaining space on the line through CSS (in our example, #center has to be 200px wide - the width of the line, 300px, minus the width of #left and #right, each 50px) ?</p> <p>Question 2: I did not find a solution through CSS and I have used jQuery to dynamically calculate the remaining available space. This works ok in all browsers except IE9.</p> <p>The problem with IE9 is that it has subpixel precision and jQuery returns only integer values for the dimensions of elements.</p> <p>Here's an example: IE9 sees #left as having 50.5px width while jQuery sees it as having 50px. This difference causes the layout to break in IE9.</p> <p>If I need to calculate the available space through JavaScript, what can I do to overcome this IE9 issue ?</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.
 

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