[英]Multiple line jquery tooltip
How to make custom jquery tooltip appear as multiple line that adjusts to fixed width? 如何使自定义jquery工具提示显示为调整为固定宽度的多行? So it not go in one long line (if 'title' attribute is very long).
所以它不会进入一个长行(如果'title'属性很长)。 Because Now if I write long 'title' attribute, tooltip is displayed on one long line and it does not matter what width is set to tooltip element.
因为现在如果我写了很长的'title'属性,工具提示会显示在一个长行上,并且设置为tooltip元素的宽度无关紧要。
My code to get better understanding of what I'm asking: 我的代码可以更好地理解我的要求:
http://jsfiddle.net/8XttH/ http://jsfiddle.net/8XttH/
jquery code: jquery代码:
$(document).ready(function() {
$("body").append("<div class='tip'></div>");
$("p[title]").each(function() {
$(this).hover(function(e) {
$().mousemove(function(e) {
var tipY = e.pageY + 16;
var tipX = e.pageX + 16;
$(".tip").css({'top': tipY, 'left': tipX});
});
$(".tip")
.html($(this).attr('title'))
.stop(true,true)
.fadeIn("fast");
$(this).removeAttr('title');
}, function() {
$(".tip")
.stop(true,true)
.fadeOut("fast");
$(this).attr('title', $(".tip").html());
});
});
});
Use this css
使用此
css
div.tip{
position: absolute;
top: 100px;
left: 100px;
width:100px;
border: 2px solid #FF0000;
background-color: #FF9999;
display: none;
padding: 3px;
}
Fiddle: http://jsfiddle.net/8XttH/2/ 小提琴: http : //jsfiddle.net/8XttH/2/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.