通过第一部分后使导航文本颜色发生变化
我一直在尝试找出如何更改导航中的字体颜色,以便在滚动经过蓝色部分进入橙色部分后进行更改。
https://tom-odell-v2.vercel.app/
这个是我正在使用的 javascript,但问题是滚动点根据屏幕尺寸而不同,我需要一些能够响应移动样式的东西。
$(document).ready(function(){
var scroll_pos = 0;
$(document).scroll(function() {
scroll_pos = $(this).scrollTop();
if(scroll_pos > 750) {
$('.change').css('color', '#244093');
} else {
$('.change').css('color', '#ffbd75');
}
}); });
我不太擅长 jquery/javacript,希望得到一些帮助或资源!
I've been trying to figure out how to change the font colour in my nav to change after scrolling past the blue section into the orange section.
https://tom-odell-v2.vercel.app/
This is what I'm working with for my javascript but the issue is that the scroll point is different depending on the screen size and I need something that is going to be responsive to mobile styling.
$(document).ready(function(){
var scroll_pos = 0;
$(document).scroll(function() {
scroll_pos = $(this).scrollTop();
if(scroll_pos > 750) {
$('.change').css('color', '#244093');
} else {
$('.change').css('color', '#ffbd75');
}
}); });
I'm not very good with jquery/javacript and would appreciate some assistance or resources!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用您正在尝试的相同方法,您可以添加多个 if 语句来实现此目的。检查下面的代码片段。
您可以使用交叉路口观察器来执行此操作。
using the same method you are trying, you can add multiple if statements to achieve this. Check the code snippet below.
You can do this using intersection observer.