css - UC手機(jī)瀏覽器下如何讓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;}
相關(guān)文章:
1. javascript - immutable配合react提升性能?2. javascript - sublime快鍵鍵問題3. css - 寫頁面遇到個(gè)布局問題,求大佬們幫解答,在線等,急!~4. 配置Apache時(shí),添加對(duì)PHP的支持時(shí)語法錯(cuò)誤5. phpstudy8.1支持win11系統(tǒng)嗎?6. javascript - nodejs關(guān)于進(jìn)程間發(fā)送句柄的一點(diǎn)疑問7. javascript - 移動(dòng)端上不能實(shí)現(xiàn)拖拽布局嗎?8. 實(shí)現(xiàn)bing搜索工具urlAPI提交9. Apache 已經(jīng)把網(wǎng)站根目錄的改為allow from all了,但是服務(wù)器還是不能訪問?10. vue.js - Vue 如何像Angular.js watch 一樣監(jiān)聽數(shù)據(jù)變化

網(wǎng)公網(wǎng)安備