logoalt Hacker News

fsmvtoday at 3:22 PM1 replyview on HN

You could set the CSS zoom property to 1/window.devicePixelRatio with JavaScript but I think you can't do it with CSS only. If you do that then px is physical px. This doesn't include browser zoom though or mobile pinch to zoom. You could also get those with JavaScript but then people would be really confused by the behavior of your website.

You definitely can't get pure integers though it's always a float even if you use whole numbers. It does eventually get rounded before becoming pixels though.


Replies

somattoday at 4:07 PM

That is sort of where I ended up, Not that it matters, Pixels should probably never actually be used. It just offends me that a unit that is sort of messy and tied to physical hardware but does provide measurement that can not be found elsewhere. gets neutered and we end up with another useless absolute unit, inch, point, millimeter, pica, the Q(did we really need the Q?) and now the pixel.