在没有JS的情况下滚动页面时应用媒体查询 [英] Apply media query when page scrolled without JS

查看:81
本文介绍了在没有JS的情况下滚动页面时应用媒体查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想在页面滚动时应用媒体查询.xxxx pixels down在没有JS的情况下,我能用媒体查询吗?

I want to apply media query only when page scrolled xxxx pixels down Is there any way I can do that with media query without JS?

已更新 我要问的原因是,基于偏移位置的JS插件都无法在iPad,iPhone和Safari上运行,它们无法正确计算偏移量 Bootstrap scrollspy无法正常运行iPad

UPDATED The reason I am asking because none of JS plugins based on offset position are working on iPad, iPhone and Safari, they are not calculating offset properly Fixed position delayed on IOS and Bootstrap scrollspy not working on iPad

所以我想如果可以的话,我可以通过媒体查询来做到这一点.

So I thought may be I can do that with media query if it is possible.

推荐答案

不,您不能通过媒体查询来做到这一点,媒体查询用于测试屏幕尺寸以进行响应式网页设计.

No you can't do that with a media query, media queries are used to test screen sizes for responsive web design.

您将不得不使用javascript检查滚动位置,然后相应地应用媒体查询.

You're going to have to use javascript to check scroll position then apply the media query accordingly.

这篇关于在没有JS的情况下滚动页面时应用媒体查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆