html - <ul> 列表背景图片,css

标签 html css

这是我的代码:

    #jackpots {
    position: relative;
    width: 228px;
    min-height: 30px;
    background: url(images/pattern.png) repeat;
    }

    .bottomImage {
    position: absolute;
    bottom: 0; 
    z-index: 1;
    }

    #jackpots ul {
    z-index: 2;
    }

HTML:

    <div id="jackpots>
        <ul>
            <li>...</li>
            <li>...</li>
            <li>...</li>
            <li>...</li>
        </ul>
    <img src"some.jpg" class="bottomImage">
    </div>

问题是:li 元素只有在其下方没有图像时才可点击。 我已经尝试使用更大的 z-index 数字,以防我的整个代码中已经有 1 或 2,但运气不好。

最佳答案

您需要更改您的 CSS:

#jackpots ul {
    position: relative;
    z-index: 2;
}

position 值更改为 relative 将允许 z-index 影响堆叠顺序,这正是您想要的。

关于html - <ul> 列表背景图片,css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18509501/

相关文章:

javascript - 使用jquery动态更改图像的href路径

jquery - 水平div不在一条线上

javascript - 为数组项添加 onclick 事件

html - 从图像生成 HTML map

html - CSS 网格 : How to make an area always on top of another area

javascript - 适用于 chrome 但不适用于 firefox、Eventlistener、appendChild 和 style.backgroundColor

html - 如何在HTML页面中添加灰色垂直线

css - 是什么导致了这个 WP 页面样式的不同?

html - 无法沿页面长度对齐下拉菜单

javascript - 仅溢出 DIV 中的一个元素