简体   繁体   中英

How to fixed position of arrow not depending on content in Jquery Tooltip?

While applying tooltip on textbox , it coming fine the only problem is that i have an issue in handing the position of arrow according to content in title attribute. For short title arrow is coming fine(middle of textbox) but for long title the arrow is going up to the textbox. Here is the JSFiddle code link:

Fiddle Link

 $(function() {
$( document ).tooltip({
  position: {
    my: "left center",
    at: "right+10 center",
    using: function( position, feedback ) {
      $( this ).css( position );
      $( "<div>" )
       .addClass("arrow")
        .addClass(feedback.vertical)
        .addClass(feedback.horizontal)
        .appendTo( this );
    }
  }
});

});

You don't need to add the extra class arrow to the tooltip. You can use the :before pseudo class on the class .ui-tooltip .

.ui-tooltip {
    padding: 10px 12px;
    color: Black;
    font: 8pt "Helvetica Neue", Sans-Serif;   
    max-width: 150px;
    background: white;
    border: 1px solid #999;
    position: absolute;
} 
.ui-tooltip:before {
    content: "";
    width: 0; 
    height: 0; 
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent; 
    border-right:10px solid #999; 
    position: absolute;
    top: 50%;
    margin-top: -10px;
    margin-left: -22px;
}

Also check this the updated Fiddle .

You can set

top:50%

Or use this

Only this code.. this is what you exactly want..:)

.arrow {
        height: 0;
        width: 0;    
        overflow: hidden;
        position: absolute;
        top: 50%;
        margin-top: -10px;
        left: -20px;
        border:10px solid #999;
        border-top-color:transparent;
        border-left-color:transparent;
        border-bottom-color:transparent;

  }

Demo Link

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM