【问题标题】:Google Chrome - z-index issue on absolutely positioned DIVsGoogle Chrome - 绝对定位 DIV 上的 z-index 问题
【发布时间】:2016-07-26 04:22:22
【问题描述】:

所以我有一个“正在开发”的网站,我在 Google Chrome 中看到了一个奇怪的问题(Edge/Internet Explorer 没有显示这个错误,但可以按预期工作,这是第一次!)

用于循环浏览标题图像的两个“下一个”和“上一个”控件的 z-index 为 666,左右浮动,但 Google Chrome 似乎没有检测到 a) 悬停事件,b)点击(据我所知)。不知道是不是和表头底部的菜单有关...

任何帮助将不胜感激!

CSS 代码如下:

#header #coverControls-prev,
#header #coverControls-next {
    position: relative;
    height: 100%;
    width: 100px;
    background-color: rgba(0,0,0,0.0);
    opacity: 0.25;
    text-align: center;

    transition: opacity 0.5s ease-in-out, background-color 0.5s ease-in-out;
    z-index: 666;
}

#header #coverControls-prev:hover,
#header #coverControls-next:hover {
    background-color: rgba(0,0,0,0.25);
    opacity: 1;
}

#header #coverControls-prev {
    float: left;
    clear: none;
}

#header #coverControls-next {
    float: right;
    clear: none;
}

#header #coverControls-prev p,
#header #coverControls-next p {
    display: block;
    position: absolute;
    top: 50%;
    margin-top: -50%;

    width: 100%;

    font-size: 10vmin;
    text-align: center;
    z-index: 667;
}

#menu {
    position: absolute;
    bottom: 0;
    left: 0;

    display: block;

    padding: 5px 2vw;
    height: 3em;
    width: 100vw;

    background-color: rgba(255,255,255,0.5);
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    color: #000000;

    z-index: 777;
}

相关网站:http://dev1.deliriousdreams.co.uk/

【问题讨论】:

  • 尝试 display:block 在 a 元素上
  • @Giri - 在 Chrome 的开发工具中添加这个似乎并不能解决问题。我在工作,所以目前无法直接编辑要测试的站点。我已经添加了 URL,以便您可以看到完整的内容。

标签: css google-chrome z-index


【解决方案1】:

将此添加到 css 中的 a 标签。您的锚标记需要宽度和高度。 display:block 允许您为锚标记添加宽度和高度。

width: 100px;
height: 100px;
display: block;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-11-21
    • 1970-01-01
    • 1970-01-01
    • 2011-06-01
    • 2019-02-22
    • 2013-02-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多