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?
Here is what works for me on all tested browsers and mobile devices (Chrome, IE, Firefox, Safari, iPad, iphone 5 and 6, Android).
The key for safari (including ios devices) is to add the other transform css rules and not just:
You need to add to it this group of rules:
Here is some working code of mine:
You need another vendor prefixed style.
Please refer below to know which browser supports what and what prefix has to be added. http://caniuse.com/#feat=transforms2d
In some cases you'll have to use:
Sometimes works better with mobile browser.