简体   繁体   English

网站在 iPhone 屏幕右侧显示空白

[英]Website is displaying a white space on right side of screen in iPhone

I am having a problem on http://eiglaw.com -- an approximately 25px wide white space/border is showing on the right side of the screen on iPhone.我在http://eiglaw.com上遇到问题 - iPhone 屏幕右侧显示大约 25 像素宽的空白/边框。 I researched the problem on stackoverflow and these posts are relevant but when I tried the various solutions offered I have not been able to fix the problem:我在stackoverflow上研究了这个问题,这些帖子是相关的,但是当我尝试提供的各种解决方案时,我无法解决这个问题:

Responsive website on iPhone - unwanted white space on rotate from landscape to portrait iPhone上的响应式网站-从横向旋转到纵向时不需要的空白

Website body background rendering a right white margin in iPhone Safari 在 iPhone Safari 中呈现右白边的网站正文背景

White space on right side of header on zoom 缩放时标题右侧的空白

I had a similar problem on iPad but was able to fix it with this media query:我在 iPad 上遇到了类似的问题,但能够通过以下媒体查询解决它:

@media only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) 
/*and (orientation : landscape)*/ {
html,
body {
width:1000px; 
}
}

I have tried various media queries targeting the html and body elements with no luck.我尝试了各种针对 html 和 body 元素的媒体查询,但没有成功。 I have looked through the entire CSS file for problems with background images, margins, padding, overflows, etc., but am really stumped.我查看了整个 CSS 文件中的背景图像、边距、填充、溢出等问题,但我真的很难过。 Does anyone out there have any suggestions?有没有人有任何建议?

Many thanks!非常感谢!

The trouble is in your <h3 class="menu-toggle">Menu</h3> (why h3, btw?), which appears to be wider than a viewport because of having width: 100% + some padding.问题出在你的<h3 class="menu-toggle">Menu</h3> (为什么是 h3,顺便说一句?),它似乎比视口更宽,因为width: 100% + 一些填充。

Try setting a box-sizing: border-box;尝试设置box-sizing: border-box; to that element.到那个元素。

This worked a treat Tigran.这对 Tigran 很有用。

I just added a global class at the top of my stylesheet:我刚刚在样式表的顶部添加了一个全局类:

 div { box-sizing: border-box; }

Cheers!干杯!

Use the following styles:使用以下样式:

body{
  overflow-x: hidden !important;
}

this will remove the overflow on the both side of the screen ie extra white space on the screen这将消除屏幕两侧的溢出,即屏幕上的额外空白

iOS是垃圾,找到解决为什么一半屏幕变白并且您不断滚动进入它的唯一方法显然是成为一个该死的程序员。

Try this试试这个

iPhone 5 - Landscape iPhone 5 - 横向

@media only screen and (min-device-width : 320px) and (max-device-width : 568px) and (orientation : landscape) { }

iPhone 5 - Portrait iPhone 5 - 人像

@media only screen and (min-device-width : 320px) and (max-device-width : 568px) and (orientation : portrait) { }

iPhone 4 iPhone 4

@media only screen and (-webkit-min-device-pixel-ratio : 1.5), only screen and (min-device-pixel-ratio : 1.5) { }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM