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

前端 未结 4 1809
谎友^
谎友^ 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:57

    I always use perspective: 1px;, for example:

    {
      margin: 50% 0 0 50%;
      perspective: 1px;
     transform: translate(-50%, -50%);
    }
    

提交回复
热议问题