jquery - TooltipClass 不适用于 jQuery UI

标签 jquery css jquery-ui jquery-ui-tooltip

我指的是 answers of this question自定义工具提示 div 样式但没有完成。这是我的 CSS:

 <style type="text/css">
        .ttExtra
        {
            background-color: Black !important;
            color:Red !important;
        }
    </style>

和 jQuery:

    <script type="text/javascript">
                $('.userdetails').tooltip({
                    tooltipSourceID: '#userprofile',
                    loader: 1,
                    //loaderImagePath: 'animationProcessing.gif',
                    //loaderHeight: 16,
                    //loaderWidth: 17,
                    width: '400px',
                    height: '200px',
                    tooltipSource: 'inline',
                    borderSize: '2',
                    borderColor :'#000000',
                    tooltipBGColor: '#efefef',
                    tooltipClass: 'ttExtra'
                }); 
</script>

我看不到我在 css 类中提到的工具提示样式。这里一定有什么问题?

谢谢。

最佳答案

在 jQuery UI 中自定义工具提示(自定义样式):

<a href="#" title="This is a tooltip">Tooltips</a>

<script>
  $(function() {
    $( document ).tooltip({
      position: {
        my: "center bottom-20",
        at: "center top",
        using: function( position, feedback ) {
          $( this ).css( position );
          $( "<div>" )
            .addClass( "arrow" )
            .addClass( feedback.vertical )
            .addClass( feedback.horizontal )
            .appendTo( this );
        }
      }
    });
  });
  </script>


  <style>
  .ui-tooltip, .arrow:after {
    background: #efefef;
    color:red;
    border:2px solid #000;
    width: 400px;
  }
  .ui-tooltip {
    padding: 10px 20px;
    color: white;
    border-radius: 20px;
    font: bold 14px "Helvetica Neue", Sans-Serif;
    text-transform: uppercase;
    box-shadow: 0 0 7px black;
  }
  .arrow {
    width: 70px;
    height: 16px;
    overflow: hidden;
    position: absolute;
    left: 50%;
    margin-left: -35px;
    bottom: -16px;
  }
  .arrow.top {
    top: -16px;
    bottom: auto;
  }
  .arrow.left {
    left: 20%;
  }
  .arrow:after {
    content: "";
    position: absolute;
    left: 20px;
    top: -20px;
    width: 25px;
    height: 25px;
    box-shadow: 6px 5px 9px -9px black;
    -webkit-transform: rotate(45deg);
    -ms-transform: rotate(45deg);
    transform: rotate(45deg);
  }
  .arrow.top:after {
    bottom: -20px;
    top: auto;
  }
  </style>

关于jquery - TooltipClass 不适用于 jQuery UI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31283924/

相关文章:

javascript - 如何使用 jquery 访问内联 css 样式属性并更改 DOM 中的属性?

javascript - Android 2.2 和 2.3 不支持位置 :fixed

css - 设置最大列宽并换行(最多两行)

html - 如何将一个 div 居中放置在底部并在中心制作另一个可实现的 div?

Jquery:如何获取单击的 'li' 标签中包含的 anchor 的 URL?

javascript - jQuery Steps 新步骤被添加到新行

html - 如何像我在许多 Google 网络应用程序中看到的那样在右下角实现 'add' FAB?

javascript - jQuery Slider 执行意外?

jquery - 如何让 div 根据 Jquery 可排序网格的高度增长?

jquery - 如何在 Django 表单中添加新的相关对象