宽度 100% 在 iOS 上不起作用

发布于 2024-12-27 06:37:03 字数 402 浏览 0 评论 0原文

由于某些原因,在 iphone 上,我的页脚不会延伸到屏幕上,即使它的 css 设置为 width: 100%。您可以在此处查看我的页脚问题的示例: http://pixelcakecreative.com/tla2/

我的页脚 css 如下:

#footer{ width:100%; margin-top:100px; position:relative; clear:left; background:#4c4c4c; float:left; padding:30px 0;}

此问题仅适用于 iOS 设备,因为布局在 PC 浏览器上运行良好。知道如何解决这个问题吗?我已经尝试了我能想到的一切。谢谢!

For some reason on the iphone, my footer doesn't stretch across the screen, even though it's css is set to width: 100%. You can view an example of my footer issue here: http://pixelcakecreative.com/tla2/

My css for the footer is as follows:

#footer{ width:100%; margin-top:100px; position:relative; clear:left; background:#4c4c4c; float:left; padding:30px 0;}

This problem ONLY applies to iOS devices, as the layout works fine on PC browsers. Any idea how to fix this? I have tried everything I can think of. Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

云淡风轻 2025-01-03 06:37:03

尝试将您的元名称视口(至少对于 iOS)简化为以下行:

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

我知道,属性比通常告诉您的要少,但它适用于我的移动项目。

现在,经过仔细检查,大多数情况下您的网站都位于“中心”下方,然后您就有包装和页脚。

用于包装器和页脚的代码是不同的。包装器有固定的 width:941px; 而页脚只有 width:100%。包装器内的大多数元素都具有 width:100% 但这仅在包装器具有 width: 941px 时才有效。

因此,您可以尝试向页脚添加相同的宽度和填充 {width:941px; padding:30px 34px;} 或类似的内容或者

您将页脚放入类似的包装器中,并使用固定的、填充等,然后让页脚保持 width:100%;

Try by simplifying your meta name viewport (at least for iOS) to the following line:

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

Less attributes than you are normally told to have, I know, but it has worked for my mobile projects.

Now, upon closer inspection, the majority if your site is under 'center', and then you have wrapper and footer.

The code used for the wrapper and the footer is different. Wrapper has a fixed width:941px; whereas footer just has width:100%. The majority of the elements inside wrapper have width:100% but that only works because wrapper has width: 941px.

So, you either try adding that same width and padding to footer {width:941px; padding:30px 34px;} or something along those lines OR

You throw footer inside a similar wrapper with a fixed with, padding, etc and then let let footer keep width:100%;

情场扛把子 2025-01-03 06:37:03

您可能缺少移动视口元标记

这是必要的,以便 iOS 等移动设备正确缩放页面到视口。您可以在此处阅读此处

You are probably missing the mobile viewport meta tag
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

This is needed so mobile devices such as iOS properly scale the page to the viewport. You can read about it here or here.

俯瞰星空 2025-01-03 06:37:03

您的 div#innerFooter 阻止页脚正确缩放,将宽度调整为 100% 就可以修复它

#innerFooter {width:100%}

your div#innerFooter is preventing the footer to scale properly, adjust the width to 100% and that should fix it

#innerFooter {width:100%}
混吃等死 2025-01-03 06:37:03

尝试将初始比例和最大比例留空并使用 user-scrollable=no。前两个在我们的响应式设计项目中犯了同样的错误。我还没弄清楚为什么。

Try leaving initial-scale and maximum-scale empty and use user-scrollable=no. The first two let to the same error in a project of ours with responsive design. I haven't figured out why yet.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文