我的博客上的大家好我使用这个脚本:
jQuery(document).ready(function () {
jQuery(".postbox").hover(function () {
tipinfo = $(this).find('.tipinfo');
var t = jQuery(this).position() + jQuery(this).width();
var leftto = t.left + jQuery(this).width() - 30;
tipinfo.css({
top: jQuery(this).position().top + jQuery(this).height() - 2,
left: leftto
});
tipinfo.show(); //vedi tooltip
}, function () {
tipinfo.hide(); //nascondi tooltip
})
});
工具提示与IE以外的所有浏览器完美配合。我知道微软的浏览器状态不起作用,所以我请求你的帮助。有一个黑客可以解决这个问题吗?
我非常感谢你的帮助
CSS:
.tipinfo {
border-radius: 3px 3px 3px 3px;
color: #FFFFFF;
display: none;
position: absolute;
width: 350px;
z-index: 1000;
}
.bgbull {
background: url(images/bgbulle.png) no-repeat scroll 0 0 transparent;
height: 29px;
line-height: 35px;
padding-left: 50px;
width: 308px;
}
.infob {
background: none repeat scroll 0 0 #151515;
border-bottom: 1px solid #151515;
border-left: 1px solid #151515;
border-right: 1px solid #151515;
line-height:1.2em;
padding: 5px
;width: 296px;
}
.bgbullbottom {
background: url(images/bgbullebottom.png) no-repeat scroll 0 0 transparent;
height: 29px;
line-height: 35px;
padding-left: 50px;
width: 308px;
}
HTML代码:
<div class="tipinfo" style="display:none;">
<div class="bgbull"></div>
<div class="infob">
<h4 style="color:#494949;font-family:arial,sans-serif;font-size:12px;font-weight:bold;"><?php the_title_attribute(); ?></h4>
<br>
<span style="color:#bbb;"><?php the_excerpt(); ?></span>
<br>
<div style="margin-top:2px;border-top:1px dotted #323232;"></div><br>
<div style="color:#bbb;">
<span class="info">Genere: </span><br />
<span class="info">Durata: </span><br />
<span class="info">Non sai se ti piace? </span>
</div>
<div class="clear"></div>
</div>
<div class="bgbullbottom"></div>
</div>
答案 0 :(得分:0)
这对我来说不合适:
var t = jQuery(this).position() + jQuery(this).width();
因为jQuery(this).position()
返回对象,但jQuery(this).width()
返回整数。可能你应该把它改成:
var t = jQuery(this).position();
t.left += jQuery(this).width();
答案 1 :(得分:0)
据我所知,您需要将悬停行为添加到IE&lt; 8。我不知道jquery是否会添加此功能,请在CSS中包含以下行:
body {/* ...*/behavior:url("/styles/csshover.htc");}
以下 csshover.htc (使用原始信用复制,可以在列出的页面上找到它)
<attach event="ondocumentready" handler="parseStylesheets" />
<script language="JScript">
/**
* Pseudos - V1.30.050121 - hover & active
* ---------------------------------------------
* Peterned - http://www.xs4all.nl/~peterned/
* (c) 2005 - Peter Nederlof
*
* Credits - Arnoud Berendsen
* - Martin Reurings
* - Robert Hanson
*
* howto: body { behavior:url("csshover.htc"); }
* ---------------------------------------------
*/
var currentSheet, doc = window.document, activators = {
onhover:{on:'onmouseover', off:'onmouseout'},
onactive:{on:'onmousedown', off:'onmouseup'}
}
function parseStylesheets() {
var sheets = doc.styleSheets, l = sheets.length;
for(var i=0; i<l; i++)
parseStylesheet(sheets[i]);
}
function parseStylesheet(sheet) {
if(sheet.imports) {
try {
var imports = sheet.imports, l = imports.length;
for(var i=0; i<l; i++) parseStylesheet(sheet.imports[i]);
} catch(securityException){}
}
try {
var rules = (currentSheet = sheet).rules, l = rules.length;
for(var j=0; j<l; j++) parseCSSRule(rules[j]);
} catch(securityException){}
}
function parseCSSRule(rule) {
var select = rule.selectorText, style = rule.style.cssText;
if(!(/(^|\s)(([^a]([^ ]+)?)|(a([^#.][^ ]+)+)):(hover|active)/i).test(select) || !style) return;
var pseudo = select.replace(/[^:]+:([a-z-]+).*/i, 'on$1');
var newSelect = select.replace(/(\.([a-z0-9_-]+):[a-z]+)|(:[a-z]+)/gi, '.$2' + pseudo);
var className = (/\.([a-z0-9_-]*on(hover|active))/i).exec(newSelect)[1];
var affected = select.replace(/:hover.*$/, '');
var elements = getElementsBySelect(affected);
currentSheet.addRule(newSelect, style);
for(var i=0; i<elements.length; i++)
new HoverElement(elements[i], className, activators[pseudo]);
}
function HoverElement(node, className, events) {
if(!node.hovers) node.hovers = {};
if(node.hovers[className]) return;
node.hovers[className] = true;
node.attachEvent(events.on,
function() { node.className += ' ' + className; });
node.attachEvent(events.off,
function() { node.className =
node.className.replace(new RegExp('\\s+'+className, 'g'),''); });
}
function getElementsBySelect(rule) {
var parts, nodes = [doc];
parts = rule.split(' ');
for(var i=0; i<parts.length; i++) {
nodes = getSelectedNodes(parts[i], nodes);
} return nodes;
}
function getSelectedNodes(select, elements) {
var result, node, nodes = [];
var classname = (/\.([a-z0-9_-]+)/i).exec(select);
var identify = (/\#([a-z0-9_-]+)/i).exec(select);
var tagName = select.replace(/(\.|\#|\:)[a-z0-9_-]+/i, '');
for(var i=0; i<elements.length; i++) {
result = tagName? elements[i].all.tags(tagName):elements[i].all;
for(var j=0; j<result.length; j++) {
node = result[j];
if((identify && node.id != identify[1]) || (classname && !(new RegExp('\\b' +
classname[1] + '\\b').exec(node.className)))) continue;
nodes[nodes.length] = node;
}
} return nodes;
}
</script>