我实现了代码来显示stackoverflow屏幕顶部的栏:
How to show popup message like in stackoverflow
这样做是在页面顶部的div顶部显示div.如何显示新的“bar”div并推送其他div?就像StackOverflow一样.
解决方法
编辑:下面对我的代码的立即反应将是不使用div #removeme标记,而是提供一个margin-bottom.但是,如果你要使用position:fixed,那么它将不起作用,因为它将自身附加到窗口而不是文档.
这就是我做的:
在我的HTML文档中:
<div id="removeme"> <br /><br /> </div> <div id="header"> This is a floating pane! </div> <div id="content"> Your content goes here... </div>
此浮动窗格的CSS为:
#header { position: fixed; top: 0px; left: 0px; text-align: center; background-color: #FFE6BF; height: 30px; border: 1px solid #FFCFA6; width: 100%; }
然后在< head>中使用jquery标签:
$(document).ready(function() { $('#header').click(function() { $('#header').slideUp('fast'); $('#removeme').remove(); }); });