html - 仅在笔记本电脑和台式机上启用视差效果?

标签 html css mobile-safari

有没有办法只在笔记本电脑和桌面 View 上触发视差效果?

Atm 我有以下内容,但它不允许在某些设备浏览器上显示图像:特定的 Safari。

.parralax {

/* Full height */
height: 100%; 

/* Create the parallax scrolling effect */
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}

我的 HTML 在我想要视差效果的部分中仅引用了它。

<section id="home" class="home parralax bg-img fix">

最佳答案

确保将外部样式表放在文档的最前面,这样它就会覆盖视差规则。

/*Mobile 480px*/
/*Desktop 992px*/
/*Huge 1280px*/

@media screen and (min-width: 480px) and (min-width: 768px), (min-width: 992px), (min-width: 1280px) {
.parralax {
   /* Full height */
   height: 100%; 

   /* Create the parallax scrolling effect */
   background-attachment: fixed;
   background-position: center;
   background-repeat: no-repeat;
   background-size: cover;
 }
} 

关于html - 仅在笔记本电脑和台式机上启用视差效果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47440582/

相关文章:

html - CSS - 具有 100% 最小高度的内容创建垂直滚动条

具有多个 CSS 类的 HTML 超链接未使用所有 CSS 样式

html - Bootstrap 3 推拉在 xs 上不起作用

html - 如何将导航栏中的文本居中

css - 能够显示一个没有确定列数的元素列表

ios - iphone 上的 extjs 应用程序

html - 背景图像不能很好地与粘性页脚一起使用

html - 额外的 div 导致图像高度无法正确缩放(显示 : flex)

javascript - iOS Safari 16 已允许地理定位,但导航器权限仍然显示 "prompt"

ipad - iPad 应用程序缓存事件无法更新屏幕