简体   繁体   English

iPhone没有完全重复背景图片

[英]iPhone not fully repeating background image

I have built a website that I thought was free from css errors until I test this on the iPhone. 我建立了一个我认为没有CSS错误的网站,直到我在iPhone上对其进行了测试。 I have a strange problem in that the repeating background images do not stretch fully across the page. 我有一个奇怪的问题,就是重复的背景图像无法完全延伸到整个页面。

This is what it looks like on an iPhone and full website URL: Example website 这是在iPhone和完整网站URL上的样子: 示例网站

iPhone图片

Try this: <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> 尝试以下操作: <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

The problem is the same for if you reduce the width of your browser. 如果您减小浏览器的宽度,问题也相同。 The problem is the background IS stretching, but the website is only as wide as the stretched background image. 问题是背景IS拉伸,但是网站的宽度仅与拉伸后的背景图像一样。 The slidey bit below the logo has a fixed width though and is creating the illusion that the background isn't stretching far enough. 徽标下方的滑动位具有固定的宽度,并且产生了一种幻觉,即背景拉伸得不够远。

The above code should fix this issue by making sure that the website zooms to fit the width of the browser. 上面的代码应通过确保网站缩放以适合浏览器的宽度来解决此问题。

Turn off auto-scaling by setting a viewport meta tag to the head section of your HTML. 通过在HTML的头部设置视口元标记来关闭自动缩放。 This sets the width of your page to match the width of the display, 这样可以设置页面的宽度以匹配显示的宽度,

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

Sadly adding the viewport to set the zoom to 100% was not what I was looking for. 可悲的是,添加视口以将缩放比例设置为100%并不是我想要的。

After debugging further I found that the problem was being caused by the large banner image at the top. 进一步调试后,我发现问题是由顶部的大横幅图像引起的。 This was a larger width than the rest of the website, by changing this to a centered background image and adding overflow hidden to the container fixed all issues. 通过将其更改为居中的背景图像并在容器中添加隐藏的溢出漏洞,该宽度比网站的其余部分要大。

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

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