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. 小程序怎么加外鏈,語句怎么寫!求救新手,開文檔沒發現2. javascript - 在 vue里面用import引入js文件,結果為undefined3. javascript - vue-resource中如何設置全局的timeout?4. html5和Flash對抗是什么情況?5. 前端 - node vue webpack項目文件結構6. Java反射問題:為什么android.os.Message的recycleUnchecked方法不能通過反射獲取到?7. php如何獲取訪問者路由器的mac地址8. 多選框寫進數據庫怎么寫9. mysql主從 - 請教下mysql 主動-被動模式的雙主配置 和 主從配置在應用上有什么區別?10. thinkPHP5中獲取數據庫數據后默認選中下拉框的值,傳遞到后臺消失不見。有圖有代碼,希望有人幫忙
