【发布时间】:2014-03-12 12:08:12
【问题描述】:
我正在尝试在滚动页面上的某些 DIV 部分时更改固定标题的背景颜色,类似于:
我使用的部分没有固定高度。
我发现了类似的问题Change background-color while scrolling
(使用这个小提琴http://jsfiddle.net/cEvJk/18/)
var t = $('#about').offset().top - 100;
$(document).scroll(function(){
if($(this).scrollTop() > t)
{
$('header').css({"background-color":"green"});
}
});
但我无法获得所有部分都重复的效果。
【问题讨论】:
-
是
header<header>标签还是一个类? -
在example你给的表头其实是有透明背景的。
-
你能展示你的小提琴或任何你目前正在工作的演示链接吗?
-
嗨 Dhiraj Shah,我已经上传了一个网站示例到 jiraff.co.uk/demo/demo.html
标签: javascript jquery css background-color