触摸友好的工具提示

发布于 2024-12-02 00:10:59 字数 337 浏览 1 评论 0原文

有人知道包含移动设备解决方案的 Jquery 工具提示吗?由于悬停状态不起作用,我猜我需要一些在点击时也起作用的东西。也许它的行为就像点击时的模式框?只是把东西扔到这里。不确定最好的解决方案是什么。

--更新--

我真的很喜欢@Alveoli建议的解决方案,但我最终自己尝试了一下。我使用 qTip 作为基础,并编写了一些弗兰肯斯坦代码来创建触摸友好的工具提示和移动友好的模式框。任何优化代码的帮助将不胜感激。这是小提琴...http://jsfiddle.net/cssguru/NQRBT/

Anyone know of a Jquery tool tip that includes a solution for mobile devices? Since the Hover state doesn't work, I'm guessing I need something that also works on click. Maybe it behaves like a modal box on click? Just throwing stuff out here. Not sure what the best solution would be.

-- Update --

I really like the solution @Alveoli suggested, but I ended up taking a stab at it myself. I used qTip as my base and wrote some Frankenstein'd code to create both touch friendly tooltips and mobile friendly modal boxes. Any help optimizing the code would be greatly appreciated. Here is the fiddle...http://jsfiddle.net/cssguru/NQRBT/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

桜花祭 2024-12-09 00:10:59

我正在寻找同样的东西并找到了这个优雅的解决方案:

http://osvaldas.info/blog/elegant-css-and-jquery-tooltip-responsive-mobile-Friendly

额外的好处是,在移动设备上,当您触摸它时它会“粘住”,而当您触摸它时它会消失你再碰它。

I'm looking for the same thing and found this elegant solution:

http://osvaldas.info/blog/elegant-css-and-jquery-tooltip-responsive-mobile-friendly

Bonus is that on a mobile it 'sticks' when you touch it and disappears when you touch it again.

萌无敌 2024-12-09 00:10:59

您可以使用 jQuery UI 工具提示 并确保工具提示在页面中的任何触摸时关闭,如下所示:

initTooltip = function ($el) {
    var closeTooltipOnClick = function (e) {

        // This code if for touch devices only.
        // We want to tooltip to close, when we touch
        // anywhere on the page, except if we touch on
        // the link itself.

        if ($(e.target).closest($el).size()) {
            // We just clicked on the link, so let's
            // not close the tooltip.
            return;
        }

        $('body').off('touchend', closeTooltipOnClick);
        $el.tooltip('close');
    };

    $el.tooltip({
        open: function () {

            if (!Modernizr.touchevents) {
                return;
            }
            // We make sure that the tootlip closes on
            // touch devices if there is a touch event anywhere.
            $('body').on('touchend', closeTooltipOnClick);
        }
    });
};

You could use jQuery UI Tooltip and make sure that the tooltip is closed on any touch in the page as follows:

initTooltip = function ($el) {
    var closeTooltipOnClick = function (e) {

        // This code if for touch devices only.
        // We want to tooltip to close, when we touch
        // anywhere on the page, except if we touch on
        // the link itself.

        if ($(e.target).closest($el).size()) {
            // We just clicked on the link, so let's
            // not close the tooltip.
            return;
        }

        $('body').off('touchend', closeTooltipOnClick);
        $el.tooltip('close');
    };

    $el.tooltip({
        open: function () {

            if (!Modernizr.touchevents) {
                return;
            }
            // We make sure that the tootlip closes on
            // touch devices if there is a touch event anywhere.
            $('body').on('touchend', closeTooltipOnClick);
        }
    });
};
夏了南城 2024-12-09 00:10:59

我曾经尝试过一个应用程序,它的工具提示是延迟加载的。例如,UI 上显示一个名为“提交”的按钮,3 秒后,标签“将数据提交到服务器”在“提交”按钮下方显示为工具提示。

考虑到新用户总是需要更多时间来完成操作,我认为这是实现工具提示的好方法。高级用户不会被打扰,而新用户在一段时间后可以看到工具提示。

I used to try an app, and its tooltips are lazy loaded. For example, a button called 'Submit' is displayed on the UI, and then 3 seconds later, the label 'Sumit your data to the server' shows as a tooltip below the 'Submit' button.

Considering the fresh users always need more time to completed actions, I think it is a good way to implement the tooltip. Senior users won't be bothered while fresh users could see the tooltip after a while.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文