我有一个外部 div,其中我有两个内部 div 来保存徽标和导航。我创建了这个小提琴http://jsfiddle.net/thiswolf/ZBMhr/1/
我希望导航基于徽标 div 居中。这是 html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title>Center Depending on another div</title>
<style type="text/css">
.container {
margin-left:2%;
}
.outer {
position:relative;
height:100px;
width:100%;
background-color:orange;
}
.inner-left {
position:relative;
float:left;
height:80%;
width:200px;
background-color:green;
margin-top:10px;
margin-bottom:10px;
}
.inner-right {
position:relative;
height:40%;
width:auto;
float:right;
background-color:pink;
}
</style>
<meta charset="uft-8">
</head>
<body>
<div class="container">
<div class="outer">
<div class="inner-left">
<h1>Logo</h1>
</div>
<div class="inner-right">
<p>Navigation</p>
</div>
</div>
</div>
</body>
</html>