我有一个网格,其中包含一些左浮动的li,具有固定的宽度和高度。问题在于当我悬停在中心的“最新产品”上时,显示的
没有被定位在顶部,而是位于下一个li下面。
编辑/突破: 如果我删除相对
编辑/突破: 如果我删除相对
li
上的z-index,在除IE7以外的所有浏览器中都可以正常工作。function productOver(){
var product_html = $(this).find(".product_html");
// Generate HTML only on first hover.
if(product_html.data("generated") != true){
var tis = $(this);
product_html.find(".name").html(tis.find("h2").html());
product_html.find(".price").html(tis.find(".price").html());
product_html.data("generated", true);
}
$(this).css('z-index','10'); //add this
product_html.stop().fadeTo('fast', 1).show();
}
当然,在 productOut 时将其设置回默认值
function productOut(){
$(this).css('z-index', '8'); //add this
$(this).find(".product_html").stop().fadeTo('slow', 0, function() {
$(this).hide();
});
}
z-index: 1;
应用于底部行的 LIs,并将更高的 z-index 应用于所有在悬停时出现的元素。这样就可以让你开始了。LI
已经有了z-index:8,出现在悬停上的元素具有z-index:999。 - John Magnolia