0

Is there any way to control whether a browser rounds fractional pixels up or down? IE rounds down by default, and Chrome rounds up, as can be seen in the following example http://jsfiddle.net/q5BQs/3/

My HTML:

<div id="percentage">
    <div class="first">50%=100px</div>
    <div class="second">50.5%=101px</div>
    <div class="third">51%=102px</div>
</div>
<br />
<div id="pixels">
    <div class="first">50px</div>
    <div class="second">50.5px</div>
    <div class="third">50.6px</div>
    <div class="fourth">51px</div>
</div>

My CSS:

#percentage {
    width: 200px;
    color: white;
}

#percentage .first {
    width: 50%;
    height: 20px;
    background-color: red;
}

#percentage .second {
    width: 50.5%;
    height: 20px;
    background-color:green;
}

#percentage .third {
    width: 51%;
    height: 20px;
    background-color:blue;
}

#pixels {
    color: white;
}

#pixels .first {
    width: 50px;
    height: 20px;
    background-color: red;
}

#pixels .second {
    width: 50.5px;
    height: 20px;
    background-color:green;
}

#pixels .third {
    width: 50.6px;
    height: 20px;
    background-color:blue;
}

#pixels .fourth {
    width: 51px;
    height: 20px;
    background-color:red;
}
Sinister Beard
  • 3,570
  • 12
  • 59
  • 95
user3058000
  • 11
  • 1
  • 2

1 Answers1

0

You can't change the way that a browser rounds fractional pixels. It's one of the inbuilt differences in the way different browsers render HTML.

Sinister Beard
  • 3,570
  • 12
  • 59
  • 95