所以基本上我希望我的#header(具有固定位置)在用户处于页面的400px高度时将其不透明度更改为0.5。如果它在400px之前并且鼠标在#header之上 - 将不透明度更改为1.
提前致谢!
答案 0 :(得分:1)
#header:hover { opacity:1; } //CSS for mouse over #header
// javascript
var head = document.getElementById("header");
if (document.body.scrollTop > 400)
head.setAttribute("style","opacity:0.5; -moz-opacity:0.5; filter:alpha(opacity=50)");
else
head.setAttribute("style","opacity:1; -moz-opacity:1; filter:alpha(opacity=100)");