我寫了一個提醒欄是這樣的:如何讓我的「提醒欄」按下我網站上的所有內容?
alertmsg{
font-family:Arial,Helvetica,sans-serif;
font-size:135%;
font-weight:bold;
overflow: hidden;
width: 100%;
text-align: center;
position: fixed;
top: 0px;
left: 0px;
background-color: #fff;
height: 56px;
color: #000;
font: 20px/40px arial, sans-serif;
display:none;
padding-top:12px;
-webkit-box-shadow: 3px 3px 5px #888;
-moz-box-shadow: 3px 3px 5px #888;
box-shadow: 3px 3px 5px #888;
}
function alertbar(m, timeout){
if(!timeout){
var timeout = 3000;
}
var $alertdiv = $('<div id = "alertmsg"/>');
$alertdiv.text(m);
$alertdiv.bind('click', function() {
$(this).slideUp(200);
});
$(document.body).append($alertdiv);
$("#alertmsg").slideDown("slow");
setTimeout(function() { $alertdiv.slideUp(200) }, timeout);
return false
}
很簡單。我呼叫alertbar("Go go go!");
將此警報下降。
但是,它覆蓋了身體的頁面。我希望它在整個頁面(所有元素)上「下推」......有點像StackOverflow,我猜。
它推動網站,因爲它正在增長/移動的DIV - 不僅使其出現。 DIV是阻止元素,所以如果你插入一個元素,一切都會改變。只是不像在這個網站上看到的那樣。 –
在css中缺少'#'? – Dogbert