JS检查浏览器是否支持CSS Snap Points
16lz
2021-01-22
Is there a simple way to check if a browser supports CSS Snap Points. I've set up a fail safe for a horizontal gallery but I'd like to turn off all the Javascript if the browser already natively supports snap points.
有没有一种简单的方法可以检查浏览器是否支持CSS Snap Points。我已经为水平图库设置了故障保护,但是如果浏览器本身支持快照点,我想关闭所有Javascript。
Also, are there any decent polyfills that might do a better job of what I've built here.
此外,是否有任何体面的polyfill可以更好地完成我在这里建立的。
1 个解决方案
#1
2
Try checking document.body
style
for "scroll-snap-type"
property
尝试检查“scroll-snap-type”属性的document.body样式
if ("scroll-snap-type" in document.body.style) {
// do stuff with `scroll-snap-points`
} else {
// `scroll-snap-points` not supported
}
更多相关文章
- jQuery Ui Draggable在移动端浏览器不起作用解决方案
- 目前最好用的“点击复制”功能,兼容主流浏览器
- ie8下jQuery动画没有ie7流畅,是浏览器性能问题吗?有没有什么解决方
- CSS样式如何解决IE浏览器不同版本的兼容问题
- 关于INPUT的autocomplete="off" 属性(浏览器表单默认的记忆功能)
- html 加上readonly后在各种浏览器的差异。
- html中显示div的时候,超出浏览器的宽,怎么解决,在线等!!!
- 我无法在某些Web浏览器中输入我的注册文本字段
- (转)让所有浏览器支持HTML5 video视频标签