javascript - 如何将 jQuery UI 工具提示与我的自定义 CSS 一起使用

标签 javascript jquery html css jquery-ui

我正在使用 jQueryUI 工具提示和自定义 CSS 对其进行格式化。工具提示即将到来,但无法在其上应用我的 css 类。 代码:

$(document).ready(function () {
    $("#roles").tooltip({ content: "Start typing a name for the IT role you're staffing. There are 75 to choose from. If you're uncertain, start with something general like '<i>Manager</i>'" });    
});

HTML

<input id="roles" type="text" class="wGridPx_16"/>

CSS

<style>
        .ui-tooltip
        {
            font-size: 11px;
            color: #fff;
            text-shadow: 0 0 2px #000;
            padding: 4px 8px;
            border: 1px solid rgba(255,255,255,0.25);
            background-color: rgb(25,25,25);
            background-color: rgba(25,25,25,0.82);
            background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(transparent), to(#000));
            border-radius: 3px;
            -webkit-border-radius: 3px;
            -moz-border-radius: 3px;
            box-shadow: 0 0 3px #555;
            -webkit-box-shadow: 0 0 3px #555;
            -moz-box-shadow: 0 0 3px #555;
        }
    </style>

请帮忙。我查过很多关于它的问答博客,比如 jquery ui tooltip custom class on page load但没有任何帮助。

最佳答案

您可以使用 tooltipClass选项

$(document).ready(function () {
    $("#roles").tooltip({
        content: "Start typing a name for the IT role you're staffing. There are 75 to choose from. If you're uncertain, start with something general like '<i>Manager</i>'",
        tooltipClass: 'my-class'
    });

});

然后

.my-class.ui-tooltip {
    font-size: 11px;
    color: #fff;
    text-shadow: 0 0 2px #000;
    padding: 4px 8px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background-color: rgb(25, 25, 25);
    background-color: rgba(25, 25, 25, 0.82);
    background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(transparent), to(#000));
    border-radius: 3px;
    -webkit-border-radius: 3px;
    -moz-border-radius: 3px;
    box-shadow: 0 0 3px #555;
    -webkit-box-shadow: 0 0 3px #555;
    -moz-box-shadow: 0 0 3px #555;
}

演示:Fiddle

关于javascript - 如何将 jQuery UI 工具提示与我的自定义 CSS 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20239396/

相关文章:

html - 如何使用 XPath 选择父节点?

javascript - window.open() 不适用于 safari ios

javascript - 引用导入的 es6 类的正确 JSDOC 语法是什么?

php - 将 javascript 对象发布到 PHP 文件

html - 不能把这些按钮放在底部

html - 我的 svg 在动画的某个时刻停止

javascript - 如何过滤和映射嵌套数组项,同时检查要过滤的项是否满足某些条件?

javascript - 只有我使用innerHTML 添加的最后一个元素保留其事件处理程序,为什么?

javascript - 我如何使用 Jquery 动态获取所有元素的属性值?

jquery - 在不触发 div.click 事件的情况下单击 div 中的链接