我想在页面向下滚动时更改标志文字颜色 [英] I want to change logo text color when the page scrolls down
问题描述
我正在创建视差网站。我面临的问题是,当页面向下滚动它不会改变标志的颜色,我想让它的蓝色,当页面向下滚动。其默认颜色现在是白色。
I'm creating the parallax website. The problem I'm facing is that when the page scrolls down its wont change the color of the logo I wanna make it blue when the page scrolls down. Its default color is white now. I don't know how to fix it.
下面的代码是当页面向下滚动时的导航代码,我想在向下滚动时更改徽标颜色。 / p>
The code down here is the nav code when the page scrolls down I want to change logo color when it scrolls down.
var a = $(".navbar-default").offset().top;
$(document).scroll(function() {
if ($(this).scrollTop() > 10) {
$('.navbar-default').css({
"background": "#fff"
});
} else {
$('.navbardefault').css({
"background": "transparent"
});
}
});
推荐答案
我唯一能想到的就是问题是你的类名称中的拼写错误接近结束( .navbardefault
)。固定后,我看到我假设的是您的预期行为。
The only thing I can think of that could be your issue is that typo in your class name near the end (.navbardefault
). When fixed I see what I assume is your intended behavior.
var a = $(".navbar-default").offset().top;
$(document).on('scroll', function() {
if ($(this).scrollTop() > 10) {
$('.navbar-default').css({
"background": "#fff"
});
} else {
$('.navbar-default').css({
"background": "transparent"
}).removeClass('after-scroll-nav-border');
}
});
body {
background: red;
height: 600px;
}
.navbar-default {
position: fixed;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a class="navbar-default">Nav Bar</a>
这篇关于我想在页面向下滚动时更改标志文字颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!