Search code examples
androidcssalignmentcenter

Android - CSS vertical centering doesn't work


The following container should be vertically centered...:

<div style="
  position:fixed;
  top:0;
  bottom:0;
  margin:auto;
  background-color:red;
  width: 50px;
  height:50px;
  z-index:555;
"></div>

...and it is in all major browsers except Android. Is there any way to vertically center this in Android as well? It displays in top left corner.


Solution

  • Have you tried

    top: 50%; margin-top: -25px;