html - CSS 相对和绝对,忽略 z-index

标签 html css

我有一个 li 的网格,它们都以固定的宽度/高度向左浮动。问题是当我将鼠标悬停在中心的最新产品上时,显示的 div 未定位在顶部并位于下一个 li 的

编辑/突破: 如果我删除相对 li 上的 z-index 这适用于除 IE7 之外的所有浏览器

最佳答案

尝试更改悬停的 LI 的 z-index 以使其大于它的 sibling ,就像在您的 productOver 函数中一样:

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(); 
  });
}

关于html - CSS 相对和绝对,忽略 z-index,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8134804/

相关文章:

html - 在语义 HTML 中,类属性在没有 CSS 或 Javascript 的情况下有什么意义吗?

html - 是否可以在高度固定但宽度可变的 div 中使用文本溢出?

javascript - 如何将一些 HTML 插入到 javascript 中

javascript - jQuery 自动滚动到元素

css - 在禁用的 IE 文本框中更改字体颜色

javascript - 为什么要从标签名称中删除空格?

javascript - 如何将日期转换为 HTML 中的单词

html - 移除容器侧面

javascript - css transitions 影响之前修改过的 css 属性

html - 右边的遗留像素 - 不必要的滚动条