html - 移动设备/iPad 上的视差效果?

标签 html css ipad mobile parallax

我在我的网站上只使用 HTML/CSS 有一个视差效果,它在所有浏览器中都有效,除了 IE7/8,我只显示一个正常的图像,这样用户就不会看到可怕的白色差距。只是想知道是否有一种解决方法可以在移动设备/iPad 等设备上查看视差效果?或者我可以设置默认图像的方式,就像我为 IE7+8 所做的那样

示例 fiddle我的视差效果。

<!--[if lte IE 7]>
    <div id="ie7_christmas_parallax">
        <img src="xmas/ie7_ie8.jpg">
    </div>
    <![endif]-->   <!--[if IE 8]>
    <div id="ie7_christmas_parallax">
        <img src="xmas/ie7_ie8.jpg">
    </div>
    <![endif]-->
<h1>My Page</h1>
<h2>Flowers, Flowers, Flowers </h2>
    <div id="slide2" class="slide" data-stellar-background-ratio="0.5" data-slide="2"> </div>

<h2>Some text goes here</h2>
<h2>Some text goes here</h2>
<h2>Some text goes here</h2>
<h2>Some text goes here</h2>
<h2>Some text goes here</h2>

#slide4 {background-image: url("http://ibmsmartercommerce.sourceforge.net/wp-content/uploads/2012/09/Roses_Bunch_Of_Flowers.jpeg");
-webkit-background-size: contain;
float: left;
margin-top:20px;
height: 450px;}

.slide {background-attachment: fixed;
height: 100%;
position: inherit;
width: 100%;
}

最佳答案

您可以使用媒体查询根据屏幕宽度更改 css 通常手机的宽度是从 320 到 768,所以:

@media (max-width: 768px) {
 // your css code here
}

关于html - 移动设备/iPad 上的视差效果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20248215/

相关文章:

css - 为什么 TD 显示在同一行的 TR 显示中?

iphone - 来自 AVPlayer 对象的 AudioQueueLevelMeterState

ipad - Storyboard ipad 仅横向

javascript - 打开新页面时保持弹出窗口打开

JavaScript 更改具有相同 ID 困境的元素的值

javascript - jQuery图像调整大小出现在整个屏幕上

css - 使用 Ruby 解析 LESS

objective-c - TableView 数据在模拟器上不可见

javascript - 如何让我平滑滚动?

PHP $_POST 正在工作,但无法获取 HTML 元素的值