1

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 調整を試しましたが、何も修正されないようです。

4

1 に答える 1

0

あなたがする必要があるのは、.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;
}
于 2013-02-01T15:01:22.510 に答える