How to fix vh(viewport unit) css in mobile Safari?

前端 未结 8 1815
慢半拍i
慢半拍i 2020-12-14 16:54

I\'ve used vh (viewport units) css in one of my projects but in mobile safari it doesn\'t work. It seems like Safari doesn\'t know what to do with vh, but it works fine in o

8条回答
  •  一向
    一向 (楼主)
    2020-12-14 17:21

    I used this CSS only hax today and it worked. iOS 8.2 iPhone Safari :

    html, body {
        ...
        width: -webkit-calc(100% - 0px);
        ...
    }
    

    Thought: Using calc seems to get Safari to convert units to px itself. Now my page is correctly full-bleed on Chrome and Safari on iOS.

提交回复
热议问题