简体   繁体   English

100% 宽度 Css 问题仅在移动端 safari

[英]100% width Css issue only on mobile safari

Here is the site in question: www.prestigedesigns.com这是有问题的网站: www.prestigedesigns.com

The problem is that my header and footer won't stretch to their assigned 100% but only on iPhone/iPad.问题是我的 header 和页脚不会伸展到他们指定的 100%,但只能在 iPhone/iPad 上。

I've tried what I think is everything and I could really use some help?我已经尝试了我认为的一切,我真的可以使用一些帮助吗? Is there anyone else that has a similar issue?还有其他人有类似的问题吗?

Thanks.谢谢。

It's kind of a viewport issue with mobile Safari, but you can get the same effect by shrinking the width of your desktop browser window and scrolling right, you'll see your background starts dropping out.这是移动 Safari 的视口问题,但是您可以通过缩小桌面浏览器 window 的宽度并向右滚动来获得相同的效果,您会看到背景开始消失。

This is because when you're setting width:100% to your #top and #header divs, you're telling them to resize to the width of the containing element, which in this case is the browser window, (or viewport).这是因为当您将width:100%设置为#top#header div 时,您是在告诉它们调整包含元素的宽度,在本例中是浏览器 window(或视口)。 You're not telling them to resize to the content within.您不是在告诉他们调整大小以适应其中的内容。

Mobile Safari's default viewport width is 980px , so it uses 980px as the width of the containing element for your divs. Mobile Safari 的默认视口宽度是980px ,因此它使用980px作为 div 的包含元素的宽度。 This is why your layout, which is around 1050px, is getting its background chopped off.这就是为什么您的布局(大约 1050 像素)的背景被切掉了。

You can fix this for mobile Safari by directly setting its viewport (read Apple's Docs ), or by adding min-width: width of your design in pixels ;您可以通过直接设置其视口(阅读Apple 文档)或添加min-width: width of your design in pixels来为移动 Safari 修复此问题; to your body .到你的body Mobile Safari will use the min-width 's value for setting its viewport, and it'll also keep it from happening in desktop browsers as well. Mobile Safari 将使用min-width的值来设置其视口,并且它也将阻止它在桌面浏览器中发生。

Set the viewport to adapt your page on any device.设置视口以在任何设备上调整您的页面。

<meta name="viewport" content="width=device-width, initial-scale=1.0" />

Set min-width:(Width of your design)px;设置min-width:(Width of your design)px; in CSS file and this issue will be solved.在 CSS 文件中,此问题将得到解决。

it's not assigned width: 100% the header is getting width: 1009px;它没有分配width: 100% header 正在获取width: 1009px; same thing with the footer.与页脚相同。

Just a hunch as I can't actually test it, but the foot element you have within footbar is set to an absolute width in pixels while the footbar is set to % - the same with your header element - try switching these to % too?只是一种预感,因为我实际上无法对其进行测试,但是您在 footbar 中的 foot 元素设置为以像素为单位的绝对宽度,而 footbar 设置为 % - 与您的 header 元素相同 - 尝试将它们切换为 % 吗?

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

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