我如何实现*的悬停对话框?

时间:2022-11-01 13:25:28

I am in love with *'s single-color "click-to-close' hovering dialog boxes that greet a user when they try to vote and aren't logged in or use the site incorrectly. Any idea how and/or what technology Jeff used to implement these neat little devices?

我爱上了*的单色“点击关闭”悬停对话框,当用户尝试投票并且未登录或未正确使用网站时会对用户表示问候。任何想法如何和/或Jeff使用的技术实现这些整洁的小设备?

EDIT: I'm specifically talking about the SQUARE dialog boxes that say "Click To Close" on them. I know how to implement the rectangular strip on the top of the screen.

编辑:我特别谈到SQUARE对话框,上面写着“点击关闭”。我知道如何在屏幕顶部实现矩形条。

2 个解决方案

#1


51  

Although I was under the impression they used jQuery's UI Dialog for this, I am not too sure anymore. However, it is not too difficult to whip this up yourself. Try this code:

虽然我的印象是他们使用了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(); });
});

With these styles:

有了这些风格:

.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;
}

And click here to see it in action.

然后点击这里查看它的实际效果。

However, I think you'd still need to tweak it a little bit to give it the right positions depending on the situation in which you are using it. I took care of this for the left position because it is working for the top, but I think there may be some situations in which it won't. All things considered, this should get you started. If you want a more robust implementation, you should check out jQuery BeautyTips which is really awesome and would make this trivial to implement.

但是,我认为您仍然需要稍微调整一下,根据您使用它的情况给它正确的位置。我把这个用于左侧位置,因为它适用于顶部,但我认为可能会出现一些情况。考虑到所有事情,这应该让你开始。如果你想要一个更强大的实现,你应该查看jQuery BeautyTips,它真的很棒,并且可以实现这一点。

#2


2  

You can use the jQuery library in conjunction with jQuery UI to create dialogs.

您可以将jQuery库与jQuery UI结合使用来创建对话框。

#1


51  

Although I was under the impression they used jQuery's UI Dialog for this, I am not too sure anymore. However, it is not too difficult to whip this up yourself. Try this code:

虽然我的印象是他们使用了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(); });
});

With these styles:

有了这些风格:

.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;
}

And click here to see it in action.

然后点击这里查看它的实际效果。

However, I think you'd still need to tweak it a little bit to give it the right positions depending on the situation in which you are using it. I took care of this for the left position because it is working for the top, but I think there may be some situations in which it won't. All things considered, this should get you started. If you want a more robust implementation, you should check out jQuery BeautyTips which is really awesome and would make this trivial to implement.

但是,我认为您仍然需要稍微调整一下,根据您使用它的情况给它正确的位置。我把这个用于左侧位置,因为它适用于顶部,但我认为可能会出现一些情况。考虑到所有事情,这应该让你开始。如果你想要一个更强大的实现,你应该查看jQuery BeautyTips,它真的很棒,并且可以实现这一点。

#2


2  

You can use the jQuery library in conjunction with jQuery UI to create dialogs.

您可以将jQuery库与jQuery UI结合使用来创建对话框。