简体   繁体   中英

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.

你有没有尝试过

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM