始终使用jQuery确保div标签位于页面顶部 [英] Always ensuring that div tag is at top of page using jquery
本文介绍了始终使用jQuery确保div标签位于页面顶部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个div标签<div id="customError">Error</div>
我希望使用jQuery这个div标签始终显示在页面顶部,因此,即使页面是可滚动的,也要使用其他单词,我希望它始终可见并位于页面顶部就像stackoverflow通知栏一样.使用JQuery是否可能?我尝试了许多操作,当页面向下滚动时,它消失了.任何帮助建议将不胜感激.
I have a div tag <div id="customError">Error</div>
I want this div tag to always appear at the top of the page using jquery, so with otherwords even if the page is scrollable I want it to be always visible and on top of the page almost like the stackoverflow notification bar. Is this possible using JQuery? I tried a number of things and it disappears when the page is scrolled down. Any help advise will be appreciated.
推荐答案
您只能使用css:
#customError {
position: fixed;
top: 0;
left: 0;
width: 100%;
/* IE6 */
_position: absolute;
_top: expression(document.getElementsByTagName("body")[0].scrollTop + "px");
}
这篇关于始终使用jQuery确保div标签位于页面顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文