cheese12345
cheese12345

Reputation: 593

z-index - logo is going behind header

I am making a website however my logo is going behind the header even though the z-index is set higher. I do not know why? I have set a positioning so why is it not working? The overlays are both transparent .png s as I wanted to make it compatible with all browsers and RGBa is not.

Photo of the problem

The css is:

@charset "utf-8";

body {
    margin-left: 0px;
    margin-right:0px;
    margin-top: 0px;
    padding:0px;
    z-index:-101;
}

#wrapper{
    margin-left:17.3875%;
}

#BG {
    height: auto;
    width: 100%;
    position: fixed;
    z-index: -100;
    left: 0px;
    top: 0px;
    min-height: 100%;
    min-width: 1040px;
}
/*HEADER*/
/*===================================================================*/
#header{
    margin:0px;
    padding:0px;
    z-index:-98;
    position:fixed;
    z-index:-99;
    width:65.225%;
    height:18.2022472%;
    background:url(WireFrame/Nav%20Bar.png)
}

.logocontainer{
    width:34.1510157%;
    height:100%;
    margin:0;
    padding:0;
    z-index:-1;
    position:absolute;
    }

.logoimage{
    max-height:100%;
    max-width:100%;
    z-index:1;
    position:absolute;
}

#navigation{

}
/*BODY*/
/*===================================================================*/
#bodyoverlay{
    background:url(WireFrame/Body.png);
    position:fixed;
    z-index:-99;
    height:100%;
    width:65.225%;
    background-repeat:repeat-y
}

#body{
    z-index:-98;
    height:100%;
    width: 100%;

}

The html is:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Home</title>
<link href="CSS.css" rel="stylesheet" type="text/css" />
</head>

<body>
<img src="file:///U|/Year 8/ICT/Webdesign/WireFrame/Background.jpg" name="BG" width="4000" height="2670" id="BG" />
<div id = "wrapper">
    <header>
    <div id = "header">
        <div class="logocontainer">
        <img src="WireFrame/Logo.png" class="logoimage" />        </div>
        <nav>
            <div id = "navigation">         </div>
        </nav>
    </div>
    </header>
    <!---->
    <div id = "body">
        <div id = "bodyoverlay">
        </div>
        <div id = "Content">
        </div>
    </div>
</div>
</body>
</html>

Upvotes: 0

Views: 395

Answers (2)

paul
paul

Reputation: 1705

There are a number of things wrong with the way you are using the z-index property:

  • Firstly, you have to define a position for each element that has a z-index.
  • Secondly, z-index does not order everything in a page absolutely -- there are different stacking contexts.
  • (You also have multiple z-indexes in the #header)

Here's an excellent article on z-index that everyone should read and that should hopefully help you clear up the issues in your code.

Upvotes: 1

Diodeus - James MacFarlane
Diodeus - James MacFarlane

Reputation: 114377

Items that are part of the layout should be CSS backgrounds, not inline images. It makes all of these issues suddenly go away.

Upvotes: 0

Related Questions