Is it possible to “snap to pixel” after a CSS translate?

前端 未结 4 1807
谎友^
谎友^ 2021-02-01 15:15

I created a modal box and vertically centred it using a technique Chris Coyer mentioned. The only problem I\'ve found with it so far is that sometimes the box is offset by half

4条回答
  •  后悔当初
    2021-02-01 15:56

    As I encountered same problem with subpixels in Chrome and in version 64 it still can't handle subpixel transform values , I decided to write small js script, that fixes subpixel problem. You can find it on github. It simply rounds transform value to full pixel.

    Hope someone will find it helpful!

提交回复
热议问题