3
msdsk
5y

CSS is truly full of surprises.
Let's say you have a simple HTML:
<div class="with-background">
    <div class="content with-margin"></div>
</div>

Now, to ensure that margin of the internal element won't "fall out" of the background, you might add padding: 0.1px to the wrapper. But, here's a fun fact: adding 0.01px still works fine, but 0.001px does not.

For my browser the cut-off seems to be somewhere around .008333332371px

Comments
  • 4
    Subpixel values really are funky.
  • 1
    @kescherRant

    I really wonder what kind of magic governs this. It seems it is 1/120th of a pixel. Why 120 though?
  • 2
    @msdsk That you'd have to ask someone affiliated with Chromium or Gecko engines.
  • 1
    Probably something to do with FPU magic?
    You know, like adding multiple times 0.1 to a number and displaying it on each iteration

    (Just guessing)
Add Comment