我正在一个必须为菜单使用固定 DIV 的网站上工作。www.atelier2architecten.nl/index2.php
我试图找到一种方法让固定的 div 水平滚动。因为,当 je 缩小浏览器窗口时,您无法单击窗口外的按钮。
我找到了一些 jquery 解决方案。但那些包括动画。我的客户不希望这样。它必须保持固定。
我还在这个网站上找到了一个很好的解决方案但是当我在我的代码中使用 DOC TYPE 时它不起作用。(我的 CSS 需要它)
这是不适用于任何 DOC TYPE 的代码:
function hscrollbar() {
var left =
/* window.pageXOffset should work for most recent browsers: */
window.pageXOffset ? window.pageXOffset :
/* If it DOESN'T, let's try this: */
document.documentElement.scrollLeft ? document.documentElement.scrollLeft :
/* And if THAT didn't work: */
document.body.scrollLeft;
/* Now that we have the horizontal scroll position, set #footpanel's left
position to NEGATIVE the value, so it APPEARS to follow the scroll: */
document.getElementById('menu').style.left = -left;
}
window.onscroll = hscrollbar; /* Call the function when the user scrolls */
window.onresize = hscrollbar; /* Call the function when the window resizes */
我希望有人可以帮助我。当我不使用 DOC TYPE 时,它可以在 google chrome 上完美运行。但是 IE 一如既往地是个问题。
问候托拜厄斯