javascript - 仅当屏幕宽度小于 600px 时,使 div 从底部消失 850px
问题描述
我有这个功能可以让我的 div 从页面底部消失 850 px
<script type="text/javascript">
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() > $(document).height() - 850) {
$('.guide').hide();
}
else {
$('.guide').show();
}
});
</script>
但我希望这仅在屏幕宽度为 600 像素或更小的情况下才会发生,我该怎么做?
解决方案
您可以使用$(window).width()
:
<script type="text/javascript">
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() > $(document).height() - 850 && $(window).width() <= 600) {
$('.guide').hide();
}
else {
$('.guide').show();
}
});
</script>
推荐阅读
- sql - 根据 postgresQL 中的时间戳将值从一个表映射到另一个表
- android - 如何更改我的 android 应用程序的内容
- c# - 查询表达式中等效的 C# LINQ zip 函数
- javascript - 年龄金字塔:3.5.1 chartjs
- java - junit core java反向字符串测试用例
- python - 删除 python 构建源存档中的父目录
- flutter - How to make a decorated border in Flutter
- nginx - 使用 NGINX 代理时 React Router 的链接位置
- python - 有没有办法将数组与字符串相乘到numpy中的字符串数组?
- swift - 如何从 Coordinator 访问 ViewController 类?