admin管理员组文章数量:1279237
The iPhone X landscape default safe area and notch solution.
I added this Question to help others avoid a headache I head trying to fix my website on the new iPhone 10
Basically, the problem is white bars
The iPhone X landscape default safe area and notch solution.
I added this Question to help others avoid a headache I head trying to fix my website on the new iPhone 10
Basically, the problem is white bars
Share Improve this question edited Oct 6, 2017 at 20:47 Moaz Mabrok asked Sep 21, 2017 at 22:55 Moaz MabrokMoaz Mabrok 74011 silver badges37 bronze badges 2- @Krunal safe area for website, not ios apps, thanks for your ment – Moaz Mabrok Commented Oct 6, 2017 at 20:40
-
@Krunal this is an example of how to use
meta
content=viewport-fit=cover
so kindly don't remove meta – Moaz Mabrok Commented Oct 6, 2017 at 20:46
2 Answers
Reset to default 9The solution is to use viewport-fit=cover
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
This will use the full screen but what about the notch.
create a class
.iphoneX{
padding: constant(safe-area-inset-top) constant(safe-area-inset-right) constant(safe-area-inset-bottom) constant(safe-area-inset-left);
}
and add it to the website wrapper and done? Yes
No. Full-width images and Full-width divs with different colors will be cut
on my website, I use <section>
to add background images or colors and add a div in the section for the content, so instead of .iphoneX
on the website wrapper, i added .iphoneX_rl
on the div
.iphoneX_rl{
padding: 0 constant(safe-area-inset-right) 0 constant(safe-area-inset-left);
}
That takes care of the right and left what about the bottom
.iphoneX_footer{
padding: 0 0 constant(safe-area-inset-bottom) 0
}
add this to -the last div ( container) in your footer
now my website looks good on iPhone X/10, looking at my website on the iPhone 8 content goes to the edge? no safe area time for js/jquery
if (navigator.userAgent.match(/(iPhone)/)){
if((screen.availHeight == 812) && (screen.availWidth == 375)){
if((window.innerHeight == "375") && (window.innerWidth == "812")){
$('.someClass,.someClass,.someClass').addClass("iphoneX_rl");
alert("ok iphone X - L");
}else{
$('.someClass,.someClass,.someClass').removeClass("iphoneX_rl");
alert("ok iphone X - P");
}
}
}
navigator.userAgent.match(/(iPhone)/)
if any iPhone
(screen.availHeight == 812) && (screen.availWidth == 375)
if iPhone 10
((window.innerHeight == "375") && (window.innerWidth == "812"))
if landscape
does your website use google maps
Add this to landscape $('#map_section').addClass("gm_iphoneX");
class
.gm_iphoneX div.gmnoprint{
margin-right: 40px !important;
}
if there is a better way to do it, or I missed something tell me THANKS
Notes: In iOS UIWebView, the screen.availHeight is equal to 768. In iOS WKWebView, the screen.availHeight is always 812.
本文标签: javascriptiPhone X website safe areaStack Overflow
版权声明:本文标题:javascript - iPhone X website safe area - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741283625a2370149.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论