朋友你好我設計了一個浮動DIV和它完美的工作,但由於一些原因,我不希望在我的代碼使用position:relative
或position:absolute
使用jQuery()浮動DIV
$(window).scroll(function() {
var topWindowPosition = $(window).scrollTop();
var leftWindowPosition = $(window).scrollLeft();
var topLeftNavHeight = 200;
if (topWindowPosition >= topLeftNavHeight) {
$("#scroll").css({ top: topWindowPosition - topLeftNavHeight, left: 0, position: 'relative' });
} else {
$("#scroll").css({ top: 0, left: 0, position: 'relative' });
}
$("#scroll").forceRedraw();
});
,你也可以看到工作演示這裏
我可以做同樣的效果,而無需使用位置,請幫助我。
在此先感謝
我會張貼相同的。雖然'marginLeft'並不是真的需要。 – keystorm 2012-04-04 11:23:16
哈哈我剛剛編輯了現有的jsFiddle,不知道他是否有其他用途。如果沒有,那麼@Kamal你可以刪除marginLeft :) – 2012-04-04 11:25:02
非常感謝你的生活救星:) – Kamal 2012-04-04 11:25:55