不知道如何使它在滾動後導航欄不透明直到懸停結束,我還想將CSS3轉換插入到此處。使用getScrollTop處理:懸停元素
這是沒有懸停的工作代碼:
<Script>
window.onload = function() {
function getScrollTop() {
if (typeof window.pageYOffset !== 'undefined') {
// Most browsers
return window.pageYOffset;
}
var d = document.documentElement;
if (d.clientHeight) {
// IE in standards mode
return d.scrollTop;
}
// IE in quirks mode
return document.body.scrollTop;
}
window.onscroll = function() {
var box = document.getElementById('navbox'),
scroll = getScrollTop();
if (scroll <= 1) {
box.style.top = "0px";
box.style.opacity = "1";
}
else {
box.style.top = (scroll + 0) + "px";
box.style.opacity = "0.25";
}
};
};
</script>
我已經嘗試添加var hoverbox = document.getElementById('navbox:Hover'),
,然後在該方式使用下面的不透明度:
if (scroll <= 1) {
box.style.top = "0px";
box.style.opacity = "1";
navbox.style.opacity = "1";
但是,這並不工作。
有關如何使用JScript進行懸停過渡的任何建議?