我正在尝试向下面的函数添加屏幕尺寸,但不起作用。我被困住了。以下作品...
$(document).ready(function(){
$(window).scroll(function(){
if ($(this).scrollTop() > 100) {
$('.hoverItem').css("line-height", "55px");
$('#header').css("background", "rgba(255, 255, 255, 1.0)");
$('#header').css("box-shadow", "0 4px 6px -6px #f8f8f8");
} else {
$('.hoverItem').css("line-height", "105px");
$('#header').css("background", "none");
$('#header').css("box-shadow", "none");
}
});
});
</script>
但是当我添加屏幕尺寸时它不起作用......
<script>
$(document).ready(function(){
if ($(window).width() < 960) {
$(window).scroll(function(){
if ($(this).scrollTop() > 100) {
$('.hoverItem').css("line-height", "55px");
$('#header').css("background", "rgba(255, 255, 255, 1.0)");
$('#header').css("box-shadow", "0 4px 6px -6px #f8f8f8");
} else {
$('.hoverItem').css("line-height", "105px");
$('#header').css("background", "none");
$('#header').css("box-shadow", "none");
}
});
};
});
</script>
您的建议将不胜感激。
翻翻过去那场雪
相关分类