gpt4 book ai didi

javascript - 我将如何实现 stackoverflow 的悬停对话框?

转载 作者:IT王子 更新时间:2023-10-29 03:14:40 25 4
gpt4 key购买 nike

喜欢 stackoverflow 的单色“点击关闭”悬停对话框,当用户尝试投票但未登录时会向他们打招呼或错误地使用网站。知道 Jeff 如何和/或使用什么技术来实现这些简洁的小设备吗?

编辑:我专门谈论上面写着“单击以关闭”的 SQUARE 对话框。我知道如何在屏幕顶部实现矩形条。

最佳答案

虽然我的印象是他们为此使用了 jQuery 的 UI 对话框,但我不太确定了。然而,自己动手做起来并不太难。试试这个代码:

$('.showme').click(function() {
$('.error-notification').remove();
var $err = $('<div>').addClass('error-notification')
.html('<h2>Paolo is awesome</h2>(click on this box to close)')
.css('left', $(this).position().left);
$(this).after($err);
$err.fadeIn('fast');
});
$('.error-notification').live('click', function() {
$(this).fadeOut('fast', function() { $(this).remove(); });
});

使用这些样式:

.error-notification {
background-color:#AE0000;
color:white;
cursor:pointer;
display: none;
padding:15px;
padding-top: 0;
position:absolute;
z-index:1;
font-size: 100%;
}

.error-notification h2 {
font-family:Trebuchet MS,Helvetica,sans-serif;
font-size:140%;
font-weight:bold;
margin-bottom:7px;
}

click here看看它的实际效果。

但是,我认为您仍然需要稍微调整一下,以便根据您使用它的情况为其提供正确的位置。我为左边的位置处理了这个,因为它对顶部有效,但我认为在某些情况下它可能不会。考虑到所有因素,这应该可以帮助您入门。如果你想要一个更健壮的实现,你应该查看 jQuery BeautyTips真的很棒,并且可以使实现起来变得微不足道。

关于javascript - 我将如何实现 stackoverflow 的悬停对话框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/758906/

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