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?
It works great on Firefox, Internet Explorer and Chrome, however not in Safari.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With