私はCSSでひどいです、私と一緒に耐えてください。Z-indexレイヤリングの苦境
3要素:.subscribe
,#pictures
,#menu
。
これらの3つは、ピクチャの上に重ねて表示する必要があります(.subscribe
と#menu
)。 CSSは以下の通りです(すべてのセレクタは正しい)。私はちょうどz-index
と考えて、ポジショニングはそれを行うだろうが、それはうまくいきません。
明らかに間違っていますか?ありがとうございました。
#slideshow * {
margin: 0;
padding: 0;
}
#slideshow {
position: relative;
padding: 14px 0 15px;
width: 926px;
height: 335px;
}
#slideshow #pictures {
background: url('images/bg.jpg');
width: 926px;
height: 335px;
left: 0;
overflow: hidden;
}
#slideshow #pictures li {
display: block;
position: absolute;
top: 0;
width: 926px;
z-index: -1;
}
#slideshow #pictures li img {
display: block;
position: relative;
bottom: 0;
}
#slideshow #menu {
list-style-type: none;
right: 0;
padding-top: 290px;
padding-right: 20px
position:relative;
}
#slideshow #menu li {
display: block;
float: right;
z-index: 3;
}
#slideshow #menu li a {
display: block;
font: 11px "Lucida Grande", "Verdana";
text-decoration: none;
padding: 7px 0 7px 28px;
z-index: 3;
color: #ccc;
line-height: 14px;
vertical-align: middle;
}
#slideshow #menu li a:hover {
color: #fff;
}
#slideshow #menu li.current a {
font: 15px "Georgia";
color: #fff;
padding: 5px 0 5px 28px;
line-height: 18px;
}
#slideshow #pictures .subscribe {
height: 91px;
width: 252px;
position: relative;
margin-top: 100px;
float: left;
bottom: 0;
z-index: 2;
background: url('images/SubscribeButton.png');
}
#slideshow #pictures .subscribe:hover {
background: url('images/SubscribeButton-Dark.png');
}
マークアップ:
<div id="slideshow">
<ul id="pictures">
<li style="visibility: hidden; zoom: 1; opacity: 0; "> <a class="subscribe"></a><img src="style/images/sample1.jpeg" alt="Slide 1" title="Sample 1" style="display: none; width:926px; height:335px "></li>
<li style="visibility: hidden; zoom: 1; opacity: 0; "><a class="subscribe"></a><img src="style/images/sample2.jpeg" alt="Buenos Aires" title="Buenos Aires" style="display: none; width:926px; height:335px "></li>
<li style="visibility: hidden; zoom: 1; opacity: 0; "><a class="subscribe"></a><img src="style/images/Slideshow-Image1.jpg" alt="Our design team creates the perfect collections of white shirts each season" title="Creation" style="display: none; width:926px; height:335px "></li>
</ul>
<ul id="menu">
<li><a href="style/images/sample1.jpeg">three</a></li>
<li><a href="style/images/sample2.jpeg">two</a></li>
<li><a id="first" href="style/images/Slideshow-Image1.jpg">one</a></li>
<li class="background" style="visibility: hidden; zoom: 1; opacity: 0; left: 0px; top: 188px; width: 166px; height: 28px; "><div class="inner"></div></li></ul>
</div>
私はこの文脈で「私と一緒にいる」と思います。 –
@ジャレッド - 私たちが彼女と服を着たいのでなければ、正しい。 –
@Sara - マークアップもいくつか投稿する必要があります。要素は単純にZインデックスのフリー・フォー・オール・ア・オール・ア・オール・フォー・オール・オール・フォー・オール・ネスト(親子関係)がどのようにポジションに影響を与えるかに影響します。しかし、#pictures&#menuは兄弟であるように見えるので、私はそれらのZ-インデックスを設定するだけでよいと思います。サブスクリプションはピクチャの子であるように見えるため、ベースオブジェクトの上部に配置する必要があります。 –