Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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

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

It works great on Firefox, Internet Explorer and Chrome, however not in Safari.

What's a workaround to center an image in Safari web browser?

like image 677
NineCattoRules Avatar asked Apr 25 '15 11:04

NineCattoRules


People also ask

Does transform work on Safari?

It works great on Firefox, Internet Explorer and Chrome, however not in Safari.

What is webkit transform vs transform?

The webkit extension helps you target specific browsers. In this case, Google Chrome and Safari. Generally the standard transform (in this case) will be used however this just ensures all browsers will be compatible.

What is CSS webkit transform?

The CSS -webkit-transform property enables web authors to transform an element in two-dimensional (2D) or three-dimensional (3D) space. For example, you can rotate elements, scale them, skew them, and more.


1 Answers

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

like image 155
Muthukannan Kanniappan Avatar answered Oct 01 '22 19:10

Muthukannan Kanniappan