gpt4 book ai didi

jquery - 通过 CSS 媒体查询调整 jQuery 选项

转载 作者:太空宇宙 更新时间:2023-11-03 21:17:54 24 4
gpt4 key购买 nike

我浏览了很多 jQuery/CSS 答案,但似乎没有一个涉及我的问题 _我使用 popin.js 在网页底部创建了一个 popin,它在用户向下滚动超过 500px 后出现 _ 大屏幕上一切正常,但我需要知道如何为小屏幕重置高度以及是否可行通过媒体查询_说'@media(max-width: 768px)'

来自 popin.js 库的代码 =

var settings = $.extend({
target : '[data-toggle="popin"]', // Target element
button : '[data-toggle="kill-popin"]', // Close Button
store : 'popin', // Cookie Name
offsetTop : 500, // Offset when to slide
duration : 400 // Speed of animation
}, options);

如何更改@media(max-width: 768px) 的 offsetTop 选项

提前致谢

最佳答案

好的,这就是答案 https://jsfiddle.net/qtsk1zwu/2/

var offsetVal = 0;
$(window).on('resize',function(){
if($(window).width() <=768){
offsetVal = 200
console.log(offsetVal)
}else{
offsetVal = 500
console.log(offsetVal)
}

})
$(window).on('load',function(){
if($(window).width <=768){
offsetVal = 200
console.log(offsetVal)
}else{
offsetVal = 500
console.log(offsetVal)
}

})

关于jquery - 通过 CSS 媒体查询调整 jQuery 选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40413843/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com