繁体   English   中英

Android 2.3上奇怪的Z-index行为

[英]Weird z-index behaviour on Android 2.3

我想我可能在Android 2.3中遇到了另一个Z-index错误。 我们有这个小部件,它在所有主要的OS /浏览器组合上都呈现为:

在此处输入图片说明

这是我们正在使用的HTML:

<ol>
    <li>
        <span class="ranking">1</span>
        <h3>
            <a href="...">TT Legends shows the exhilaration of motorbike racing</a>
        </h3>
        <span class="score-bar" style="width: 610px;"></span>
    </li>
    <li>
        <span class="ranking">2</span>
        <h3>
            <a href="...">101-year-old grandmother 'comes back from the dead'</a>
        </h3><span class="score-bar" style="width: 421px;"></span>
    </li>
</ol>

这是CSS:

.trending ol {
    counter-reset: item;
    list-style-type: none;
    overflow: hidden;
}

.trending li {
    position: relative;
    min-height: 42px;
    margin-bottom: 10px;
    overflow: hidden;
}

.trending .ranking {
    display: table-cell;
    vertical-align: middle;
    min-width: 40px;
    text-align: center;
}

.trending h3 {
    display: table-cell;
    vertical-align: middle;
    position: relative;
    z-index: 2;
    width: 100%;
    margin-left: 40px;
    padding: 5px;
    line-height: 1.2;
}

.score-bar {
    display: inline-block;
    position: absolute;
    top: 0;
    bottom: 0;
    left: 40px;
    width: 0;
    z-index: 0;
    background: #f3f5f9;
}

我们使用JS根据相关项目的得分设置蓝色.score-bar跨度的宽度。

在HTC Desire和Samsung Galaxy S2等Android 2.3设备上,其最终结果如下:

在此处输入图片说明

谁能提出解决方案? 我已经尝试了所有可以想到的CSS调整,但是似乎没有任何解决办法。

您需要做的是将.score-bar背景样式移动到跨度以外的其他样式。

删除分数栏范围,然后使用以下内容。

这是jsfiddle示例... http://jsfiddle.net/qaYbS/

注意:在jsfiddle中,我使用了背景色,对于您的实例,您将需要使用实际图像。 只需制作一个图像即可,即您所需的高度和1px的宽度,然后使用它。 它根本不会增加加载时间。 这是使背景宽度相应缩小的唯一方法。 您可以限制背景颜色的大小。

.trending li:nth-child(1) {
    background: red;
    background-image: ;
    background-size: 610px 20px;
    background-position: 40px 0px;
}
.trending li:nth-child(2) {
    background: blue;
    background-image: ;
    background-size: 421px 20px;
    background-position: 40px 0px;
}
.trending li:nth-child(3) {
    background: green;
    background-image: ;
    background-size: 300px 20px;
    background-position: 40px 0px;
}
.trending li:nth-child(4) {
    background: orange;
    background-image: ;
    background-size: 200px 20px;
    background-position: 40px 0px;
}
.trending li:nth-child(5) {
    background: purple;
    background-image: ;
    background-size: 100px 20px;
    background-position: 40px 0px;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM