Hallo zusammen,
ich würde gerne drei übereinanderliegende Elemente in der Browsermitte zentrieren.

Im <body> habe ich ein Hintergrundbild mit background-position: center zentriert. Darüber befindet sich ein halbtransparenter Layer mit position:relative, margin:auto. Die beiden Elemente stehen ordnungsgemäß auf Mitte im Browser.
Das oberste Element, die Navigationsleiste, bekomme ich aber nicht vom linken Rand des darüberliegenden divs weg - egal, in welches tag ich nun position:relative / margin:auto schreibe. Woran mag das liegen?
Hier das HTML:
Und hier mein CSS:
ich würde gerne drei übereinanderliegende Elemente in der Browsermitte zentrieren.

Im <body> habe ich ein Hintergrundbild mit background-position: center zentriert. Darüber befindet sich ein halbtransparenter Layer mit position:relative, margin:auto. Die beiden Elemente stehen ordnungsgemäß auf Mitte im Browser.
Das oberste Element, die Navigationsleiste, bekomme ich aber nicht vom linken Rand des darüberliegenden divs weg - egal, in welches tag ich nun position:relative / margin:auto schreibe. Woran mag das liegen?
Hier das HTML:
HTML:
<!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>Menubar</title>
<link rel="stylesheet" href="menu.css" type="text/css" media="screen"/>
</head>
<body>
<div id="layer">
<div id="navbar">
<ul>
<li>
<a href="#">Home</a>
</li>
<li>
<a href="#">Reiseziele</a>
</li>
<li>
<a href="#">Angebote</a>
</li>
<li>
<a href="#">Service</a>
</li>
<li>
<a href="#">Kontakt</a>
</li>
<li>
<a href="#">Suche</a>
</li>
</ul>
</div>
</div>
</body>
</html>
Code:
@charset "utf-8";
* {
margin: 0;
padding: 0;
}
body {
font-family: "Lucida Grande", Verdana, Helvetica, Arial, sans-serif;
font-size: 9px;
background-image: url(media/himalaya2.jpg);
background-repeat: no-repeat;
background-position:center;
color: rgb(51, 51, 51);
}
#layer {
position: relative;
margin:auto;
width: 900px;
height: 768px;
background-color: rgba(255,255,255,0.7);
border: 1px solid white;
-moz-border-radius: 7px;
}
#navbar {
position: relative;
top: 50px;
}
#navbar ul, #navbar ul li {
height: 25px;
float: left;
}
#navbar ul {
-moz-border-radius: 7px;
list-style-type: none;
}
#navbar ul li {
width: 110px;
text-align: center;
background-image: url(media/bg_button.png);
background-position: bottom;
background-repeat: repeat-x;
background-color: white;
border-top: 1px solid rgb(220,220,220);
-moz-box-shadow: 0px 4px 5px rgba(0, 0, 0, 0.4);
line-height: 28px;
}
#navbar ul li:first-child {
-moz-border-radius-topleft: 7px;
-moz-border-radius-bottomleft: 7px;
}
#navbar ul li:last-child {
border-bottom-style: none;
-moz-border-radius-topright: 7px;
-moz-border-radius-bottomright: 7px;
}
#navbar ul li a {
font-size: 11px;
color: rgb(80,80,80);
font-weight: bold;
text-decoration: none;
display: block;
}
#navbar ul li a:hover {
background-color: #87a8b9;
color: #fff;
}