gpt4 book ai didi

javascript - 如何使 Twitter 样式的警报贴在窗口顶部?

转载 作者:行者123 更新时间:2023-11-30 13:40:27 24 4
gpt4 key购买 nike

这里有一个关于如何制作漂亮的 jQuery Twitter 风格警报的优秀代码示例:

http://blog.codecrate.com/2009/10/twitter-style-alerts-in-rails.html

$(function () {
var alert = $('.alert');
if (alert.length > 0) {
alert.show().animate({height: alert.outerHeight()}, 200);

window.setTimeout(function() {
alert.slideUp();
}, 3000);
}
});

但是,代码未包含的一件事是将警报 div 粘贴到窗口顶部的功能,无论用户向下滚动页面多远。

我找到了一些例子,但似乎没有什么能很好地与现有代码一起使用。

有什么想法吗?

最佳答案

您可以使用 CSS 样式:position: fixed 虽然我认为 IE 对此有一些问题(不足为奇......)。

关于javascript - 如何使 Twitter 样式的警报贴在窗口顶部?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2616477/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com