13

このコードは、IE8を除いて、私が試した他のすべてのブラウザーで機能します。

IE8はz-indexを無視しているように見えます-そしてポップアップはポップアンダーになります。

サムネイルの下に表示されるだけで、適切な場所に配置されます。

誰?

ありがとう!

HTML:

<a class="thumbnail" href="#thumb">
    <img src="comic_a3_thumb.jpg" height="300" width="212" border="0"
         style="float:right; margin-top:10px;margin-bottom:10px;"
         alt="description" />
    <span>
        <img src="/images/comic_a3_popup.jpg" />
    </span>
</a>

CSS:

.thumbnail{
    position: relative;
    z-index: 0;
}

.thumbnail:hover{
    background-color: transparent;
    z-index: 50;
}

.thumbnail span{ /*CSS for enlarged image*/
    position: absolute;
    background-color: lightyellow;
    padding: 5px;
    left: 0px;
    border: 1px dashed gray;
    visibility: hidden;
    color: black;
    text-decoration: none;
}

.thumbnail span img{ /*CSS for enlarged image*/
    border-width: 0;
    padding: 2px;
}

.thumbnail:hover span{ /*CSS for enlarged image on hover*/
    visibility: visible;
    top: -140px; /*position where enlarged image should offset horizontally */
    left: -500px;
}
4

4 に答える 4

15

簡単な答えは、z-index値より大きい.thumbnail:hover値を のホバー状態に追加することですspan

.thumbnail:hover span{ /*CSS for enlarged image on hover*/
    visibility: visible;
    top: -140px; /*position where enlarged image should offset horizontally */
    left: -500px;
    z-index: 51;
}
于 2009-08-17T20:36:08.813 に答える
6

これらの行をページの頭に入れます

<!--[if IE]>
    <style>
            #your_faulty_div{
            background-color:#000; /*any color it doesn't matter*/
        filter: alpha(opacity=0);
        }
        </style>
<![endif]-->

your_faulty_div は、IE の z-index バグが原因で誤動作している div です。

スムーズに動作します。要素を重ねて配置したすべてのプロジェクトで使用しています。

于 2010-05-15T08:02:46.623 に答える
2

私があなたを正しく理解していればspan、サムネイルとしてマークされた要素の上に表示する必要があります。要素に が指定z-indexされていません。spanこれが実際の例です:

<!DOCTYPE HTML>
<html>
<頭>
    <meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
    <title>ポップアップ テスト</title>
    <style type="text/css">
        #vbox {
            境界線: 1 ピクセルの黒一色。
            高さ: 200px;
            位置: 相対;
            幅: 200px;
            Z インデックス: 0;
        }

        #vbox:ホバー #hbox {
            表示ブロック;
        }

        #hbox {
            境界線: 1px 単色の青;
            表示: なし;
            高さ: 200px;
            左: 50px;
            位置: 相対;
            上: 50px;
            幅: 200px;
            Z インデックス: 1;
        }
    </style>
</head>
<本体>
    <div id="vbox">
        <p>このボックスにカーソルを合わせると、非表示の「ポップアップ」が表示されます。</p>
        <p id="hbox">このボックスはポップアップです。</p>
    </div>
</body>
</html>
于 2009-08-17T20:46:08.200 に答える