z-index没有应该分层

时间:2013-02-02 07:19:24

标签: css z-index layer

我对z-index有点帮助...
我正在玩代码,需要我的id =“hidebar”才能坐在“content”和“content-inner”div之上。对不起,如果这看起来很基本,但我很挣= D

我的CSS结构文件:

body
{
    margin: 0; 
    padding: 0;
    height:100%;
    width:100%;
    background-color: #FFF;
    z-index:-1;
} 
#content
{
    width: 100%;
    height: 640px;
    background-color:#060;
    position:relative;
    z-index:-1;
}
#content-inner
{
    width: 960px;
    height: 640px;
    background-color:#666;
    margin-left:auto;
    margin-right:auto;
    position:relative;
    z-index:-1;
}

#hidebar
{
    width: 100%;
    height: 50px;
    background-color:#0FF;
    position:relative;
    z-index:2;
}



#navbar
{
    width: 100%;
    height: 257px;
    background-color:#F00;
    position:relative;
}
#navbar-inner
{
    width: 960px;
    height: 257px;
    background-color:#666;
    margin-left:auto;
    margin-right:auto;
    position:relative;
}

#footer
{
    width: 100%;
    height: 181px;
    background-image:url(images/gray-pixel.png);
    position:relative;  
}
#footer-inner
{
    width: 960px;
    height: 181px;
    background-color:#666;
    margin-left:auto;
    margin-right:auto;
    position:relative;
}
#footer-small
{
    width:230px;
    float:left;
    height:100%;
    background-color:#999;
    position:relative;
}
#footer-large
{
    width:500px;
    float:left;
    height:100%;
    background-color:#CCC;
    position:relative;
}
#colour-bar
{
    width: 100%;
    height: 13px;
    background-color:#639;
    position:relative;
}


html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote,     pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s,     samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li,     fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article,     aside, details, figcaption, figure, footer, header, hgroup, mark, menu, meter, nav, output,     progress, section, summary, time {
    margin: 0;
    padding: 0;
    border: 0;
    outline: 0;
    font-size: 100%;
    vertical-align: baseline;
    background: transparent;
}
ul {
    list-style-type:none;
}
ul li a{
    font:700 49px/1.2em Arial, Helvetica, sans-serif;
    color:#fff;
    text-decoration:none;
    height:59px;
    display:inline-block;
    list-style-type:none;
    text-align:center;
    position::relative;
    vertical-align: baseline;
}

ul li a:hover{
    color:#e25709;
}
div.table 
{
    border: 0px solid black; 
    display: table;
    margin-left:auto;
    margin-right:auto;
}
div.tr {border: 0px solid black; display: table-row; }
div.td {border: 0px solid black; display: table-cell; }




h3
{
    color:#FFF;
    font-size:22px;
    font-family:Arial, Helvetica, sans-serif;
    padding-top:30px;
    padding-left:25px;
    padding-bottom:20px;
}

h4
{
    color:#FFF;
    font-size:13px;
    font-style:normal;
    font-family:Arial, Helvetica, sans-serif;
    padding-left:25px;
    padding-right:25px;
    line-height:1.2em;
}




我的源代码:          

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link rel="stylesheet" type="text/css" href="css/structure.css"/>
<script src="http://code.jquery.com/jquery-latest.js"></script>

</head>




<body>
    <div id="content">
        <div id="content-inner">
            <a href="index.html">
                <img src="images/logo.jpg"/ alt>
            </a>
        </div>
    </div>

    <div id="hidebar">
    </div>

    <div id="colour-bar"></div>
    <div id="navbar">
        <div id="navbar-inner">

            <ul>
                <li><a href="#" rel="1"><button1>About us</button1></a></li>
                <li><a href="#" rel="2"><button2>Partners</button2></a></li>
                <li><a href="#" rel="3"><button3>Solutions</button3></a></li>
                <li><a href="#" rel="4"><button4>Services</button4></a></li>
            </ul>
        </div>
    </div>
    <div id="footer">
        <div id="footer-inner">
            <div id="footer-small"></div>
                <div id="footer-large">
                    <div class="table">
                        <div class="tr">
                            <div class="td">
                                <h3>Contact Us:</h3>
                            </div>
                            <div class="td">
                            </div>
                        </div>
                        <div class="tr">
                            <div class="td">
                                <h4>AUS - Melbourne<br />
                                101 Main Street<br />
                                Glen Iris VIC 3146</h4>
                            </div>
                            <div class="td">
                                <h4>Email: mail@website.com<br />
                                Phone: (03) 9888 8888<br />
                                Fax: (03) 9888 8888</h4>
                            </div>
                        </div>
                    </div>
                </div>
            <div id="footer-small"></div>
        </div>
    </div>

<script>
$("button1").click(function () {
$("h4").toggle("slow");
$("button1").toggle();
$("button2").show();
$("button3").show();
$("button4").show();
});

$("button2").click(function () {
$("h4").toggle("slow");
$("button2").toggle();
$("button1").show();
$("button3").show();
$("button4").show();
});

$("button3").click(function () {
$("h4").toggle("slow");
$("button3").toggle();
$("button1").show();
$("button2").show();
$("button4").show();
});

$("button4").click(function () {
$("h4").toggle("slow");
$("button4").toggle();
$("button1").show();
$("button2").show();
$("button3").show();
});
</script>

</body>
</html>





任何帮助都会令人惊讶&lt; 3

1 个答案:

答案 0 :(得分:0)

如果您希望#hidebar位于#contents#content-inner之上,则只需重新定位#hidebar

<div id="content">
        <div id="content-inner">
            <div id="hidebar">

            </div>
            <a href="index.html">
                <img src="images/logo.jpg" />
            </a>
        </div>
    </div>