Why on Safari the transform translate doesn't work correctly?

前端 未结 3 2060
甜味超标
甜味超标 2020-12-03 07:04

I often use this code to center a div in view:

.centered {
  position: fixed;
  top: 50%;
  left: 50%;
  /* bring your own prefixes */
  transfo         


        
3条回答
  •  一整个雨季
    2020-12-03 07:53

    You need another vendor prefixed style.

    .centered {
      position: fixed;
      top: 50%;
      left: 50%;
      /* bring your own prefixes */
      -webkit-transform: translate(-50%, -50%);
      transform: translate(-50%, -50%);
    }
    

    Please refer below to know which browser supports what and what prefix has to be added. http://caniuse.com/#feat=transforms2d

提交回复
热议问题