css - UC手机浏览器下如何让div水平垂直居中。
问题描述
UC浏览器在宽高固定下,margin:auto,上下左右0;不能水平垂直居中是什么原因?
CSS#globalTip{ position: fixed; left: 0; right: 0; top:0; bottom:0; z-index: 99999; width:75%; height: 50px; line-height: 50px; text-align: center; background-color: #000; color:#fff; font-size: 1.6rem; border-radius: 20px;}
如果position:absolute就可以,但这并不是我想要的。
问题解答
回答1:display: table-cell;vertical-align: middle;
回答2:我后来换了另一种水平垂直居中写法
css#globalTip{ position: fixed; left:50%; top:50%; z-index: 99999; margin-left: -35%; margin-top:-25px; width:75%; height: 50px; line-height: 50px; text-align: center; background-color: nth($theme-color,1); color:#fff; font-size: 1.6rem; border-radius: 20px;}
但依然想知道UC浏览器用原写法怎么解决bug
回答3:在absolute和fixed定位方式下使用
#globalTip{ position: fixed; left:50%; top:50%; -webkit-transform:translate3d(-50%,-50%,0); transform:translate3d(-50%,-50%);}回答4:
我也遇到了相同的问题uc下 水平垂直居中不管事解决方案
.box{ display: flex; justify-content: center; align-items: center;}
相关文章:
1. python - 求一个在def中可以实现调用本def满足特定条件continue效果的方法(标题说不太清楚,请见题内描述)2. $fields = $values = [];这条代码一直定义不了,一直报错,老师的源码也是被报错的,执行不了,请问该怎么解决这个问题3. USE关键字4. javascript - mysql插入数据时怎样避免与库中的数据重复?5. MySQL 这句 创建表结构语句的错误在哪?6. 导入phpmyadmin的时候报错了7. MySQL能否给某个字段的值设置有效期?8. MYSQL新建用户设置可以远程访问的问题9. mysql数据库做关联一般用id还是用户名10. MySQL 如何 SELECT 除去某一列的所有列?
![$fields = $values = [];这条代码一直定义不了,一直报错,老师的源码也是被报错的,执行不了,请问该怎么解决这个问题](http://www.haobala.com/attached/image/news/202205/093622cb60.png)