背景图像在 iPhone 和移动设备上移动并重叠,需要解决方法
我有一个包装器 div,它包装了我的页面标题,如下所示:
<div id="wrapper">
<div id="centered_slideshow">
// Slideshow here, covering approx 75% of screen width...
</div>
</div>
#wrapper{
width:100%;
min-width:980px;
background:#000 url(../graphics/header_wrapper_bgr_left.jpg) no-repeat bottom left;
}
#centered_slideshow{
margin:0 auto; //for centering the div inside the wrapper
}
现在,整个网站在移动设备上看起来都很棒,除了这一张背景图像。 移动设备的宽度明显更小。这导致背景图像被“移动”到移动屏幕的左下角,并且由于幻灯片位于屏幕中间,因此它与幻灯片部分重叠。即背景图像与幻灯片重叠,这是我的问题。
如何使图像不在移动设备中显示,同时使背景图像在屏幕宽度变小时(如在移动设备中)变小时根本不移动?
如果您需要更多意见,请告诉我。
I have a wrapper div which wraps the header of my page like below:
<div id="wrapper">
<div id="centered_slideshow">
// Slideshow here, covering approx 75% of screen width...
</div>
</div>
#wrapper{
width:100%;
min-width:980px;
background:#000 url(../graphics/header_wrapper_bgr_left.jpg) no-repeat bottom left;
}
#centered_slideshow{
margin:0 auto; //for centering the div inside the wrapper
}
Now the entire website looks great in mobile devices, except for this one background image.
The mobile device has a significantly smaller width. This results in the background image beeing "moved" into the bottom left of the mobile screen, and since the slideshow is in the middle of the screen it partly overlaps the slideshow. ie the background image overlaps the slideshow, which is my problem.
How can I make the image not beeing shown in mobile devices, alt making the background image not move at all when the screen width gets smaller (as in mobile devices)?
If you need more input let me know.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用媒体查询来检查屏幕尺寸,然后为移动设备提供不同的背景。所以类似
更多关于媒体查询的内容: http://www.w3.org/TR/css3 -mediaqueries/
您也可以使用 jQuery 来执行此操作,但只有当您已经在网站上使用 jQuery 时,我才建议您这样做。 (最好不要让用户因下载过多的脚本而超载。)在这种情况下,
You could use a media query to check the screen size and then serve the mobile device with a different background. So something like
More on media queries here: http://www.w3.org/TR/css3-mediaqueries/
You could also use jQuery to do this, but I would advise this only if you are already using jQuery for the site. (Best not to overload the user with too many script downloads.) In this case,