如何使用jQuery UI工具提示和我的自定义CSS

时间:2013-11-27 10:06:50

标签: 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上检查了许多Q / A博客,但没有任何帮助。

1 个答案:

答案 0 :(得分:0)

您可以使用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