0

ここで z-index について多くの質問があることは知っていますが、しばらくの間 z-index を使用していて、常に正常に機能していましたが、今はこれに苦労しており、その理由がわかりません必要な手順をすべて実行したと思うため、機能していません。

test.html

<!DOCTYPE html>
<html>
    <head>
        <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
        <meta content="utf-8" http-equiv="encoding">

        <link href="style.css" rel="stylesheet" type="text/css" />

        <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js " type="text/javascript"></script>
        <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js" type="text/javascript"></script>
        <script src="http://ajax.aspnetcdn.com/ajax/mvc/3.0/jquery.validate.unobtrusive.js" type="text/javascript"></script>

        <script type="text/javascript">
            $(document).ready(function(){
                $('.boxGrid').hover(function(){
                    $(".boxCaption", this).stop().animate({bottom:'0px'},{queue:false,duration:300});
                }, function() {
                    $(".boxCaption", this).stop().animate({bottom:'-121px'},{queue:false,duration:300});
                });
            });
        </script>
    </head>
    <body>
        <div style="position: relative; width: 226px; height: 246px;">
            <div class="boxGrid">
                <div class="buttonBack blogImg">
                    <div class="boxCaption">
                        <h3>Top-Blog</h3>
                    </div>
                </div>
            </div>
        </div>
    </body>
</html>

スタイル.css

.boxGrid
{
    width: 226px;
    height: 246px;
    background-image: url(buttonBorder.png);
    position: absolute;
    top: 0px;
    left: 0px;
    z-index: 100;
}

.buttonBack
{
    position: absolute;
    top: 12px;
    left: 13px;
    border: 0px;
    width: 200px;
    height: 223px;
    z-index: 50;
    overflow: hidden;
}

.blogImg
{
    background-image: url(blogButton.png);
}

.boxCaption
{ 
    position: absolute;  
    background: url(caption.png);
    height: 121px;
    width: 100%;
    bottom: -121px;
    text-align: center;
}

.boxCaption h3
{
    font-size: 30px;
    color: #fff;
}

.boxGridしたがって、このクラスをクラスの上に置きたいので、 z-index を使用しているすべての div にプロパティを.buttonBack追加しました。position:

JsFiddleであるため、赤いボックスは青いボックスの後ろにある必要があります。

前もって感謝します

4

2 に答える 2

2

div.boxGrid の子として div.buttonBack があります。HTML の順序を変更する必要がある場合があります。

<div style="position: relative; width: 226px; height: 246px;">
    <div class="buttonBack></div>
    <div class="boxGrid">
        <div blogImg">
            <div class="boxCaption">
              <h3>Top-Blog</h3>
         </div>
     </div>
</div>
于 2012-12-14T17:09:07.010 に答える