jquery - 无法在 qtip 中使用 "style option"应用样式

标签 jquery html css qtip qtip2

我正在尝试使用文档中给出的 qtip 样式选项应用样式 styling demo但它不会影响我的代码,它会覆盖 jquery.qtip.min.css 样式类。有什么方法可以让我同时使用两者,但优先考虑样式选项

这是我的引用代码

html代码:

<div id="styleChange1" class="innerDiv">Hover to get styled qtip</div>

js代码:

$(document).ready(function() {
     $("#styleChange1").on({
           mouseover: function () {
               ShowQtip(element1,"bottomMiddle","bottomMiddle","topMiddle") ;
           },
           mouseleave: function () {
                $(this).qtip("destroy");
           }
    });
});

function ShowQtip(element,contentTxt,position1,position2) {
    if(element == null)
        return
    element.qtip({
        content: contentTxt,
        show: true,
        position: {
            my: position1,  // Position my top left...
            at: position2
        },
        hide: {
            event: false
        },
        style: { 
            width: 200,
            padding: 5,
            background: '#A2D959',
            color: 'black',
            textAlign: 'center',
            border: {
            width: 7,
            radius: 5,
            color: '#A2D959'
        }, 
        tip: contentTxt,
        name: 'dark' // Inherit the rest of the attributes from the preset dark style
   });
}

请提出任何建议。

最佳答案

尝试使用此代码...

$("jqueryselector").qtip({
   content: 'Stems are great for indicating the context of the tooltip.',
   style: { 
      tip: { // Now an object instead of a string
         corner: 'topLeft', // We declare our corner within the object using the corner sub-option
         color: '#6699CC',
         size: {
            x: 20, // Be careful that the x and y values refer to coordinates on screen, not height or width.
            y : 8 // Depending on which corner your tooltip is at, x and y could mean either height or width!
         }
}  }  });

关于jquery - 无法在 qtip 中使用 "style option"应用样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30773425/

相关文章:

javascript - 鼠标离开时悬停和反转时跨浏览器动画 gif

javascript - 单击放大 img,再次单击最小化

javascript - 如何修复从轮播中添加和删除元素的代码?

javascript - 按钮 - 仅当 JavaScript 函数返回 true 时才进行回发

javascript - 在 javascript 中向 ListView 添加元素时出现问题?

javascript - 使用 Javascript 禁用 HTML 表单中的字段取决于从下拉列表中选择的值

javascript - 在 IndexedDB 中存储图像文件

javascript - 根据其他元素调整高度

javascript - jQuery .css() 方法不起作用

html - 在此上下文中,元素输入不允许作为元素 ul 的子元素