我有 3 个 div,我希望它们显示在相同的高度左右,但现在还没有发生。
概念证明: https : //dl.dropboxusercontent.com/u/51736887/Untitled.png(必须有 10 个代表才能发布图片哦)
问题是侧边栏和主要内容是彼此下方的一个,并且像我想要的那样粘在导航栏下方而不是像我想要的那样。所发生情况的图片:https ://dl.dropboxusercontent.com/u/51736887/Untitled%20-%20Copy.png
这是我当前的代码(仅包括 2 个侧边栏中的 1 个):
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<link href="stylesheets/public.css" media="all" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
</head>
<body>
<h3 align="center"><img src="afterlogo.png" alt="" height="358" width="339"></h3>
<div id="nav">
<ul>
<li><a href="#">Home</a></li>
<li><a href="/public/forums/">Forums</a></li>
<li><a href="/public/donate.php">Donations</a></li>
<li><a href="/vote">Vote</a></li>
</ul>
</div>
<div class="content">
<p><b> test </b> 0000-00-00 00:00:00<br><b> test 2 </b> 0000-00-00 00:00:00<br>test3 0000-00-00 00:00:00<br>test4 0000-00-00 00:00:00<br>test <br />test <br />test <br />test <br />test <br />test <br />test <br />test <br />test <br />test <br /> </p>
</div>
<div class="sidebar"> test </div>
<div class="footer">
<br />
Test footer
<br />
</div>
</html>
继承人的CSS:
body {
background-image:url('../bg.png');
background-attachment: fixed;
background-position: bottom;
}
#nav a:link{
text-decoration: none;
color: #000000;
font-size: 2em;
}
#nav a:visited {
color:#000000;
}
#nav a:hover {
color: #00FF00;
}
#nav {
border-radius: 15px;
background-size: cover;
background: rgba(76, 92, 70, 0.7);
background-position: top;
text-align: center;
overflow: hidden;
position: relative;
margin:6em;
background-repeat: no-repeat;
word-spacing: 2em;
}
.nav {
text-decoration: none;
}
li {
display: inline;
}
.content {
border-radius: 15px;
background-size: cover;
/*background-image:url('../content.png');*/
background: rgba(76, 92, 70, 0.7);
background-position: top;
text-align: center;
overflow: hidden;
position: relative;
margin-left: auto ;
margin-right: auto ;
width: 500px;
background-repeat: no-repeat;
}
.sidebar {
border-radius: 15px;
/*background-size: cover;*/
background: rgba(76, 92, 70, 0.7);
background-position: top;
text-align: left;
overflow: hidden;
margin-left: 120px;
margin-right: auto;
width: 220px;
float: left;
}
.footer {
clear:both;
border-radius: 500px;
text-align: center;
background: rgba(76, 92, 70, 0.7);
background-position: top;
text-align: center;
overflow: hidden;
position: relative;
margin:6em;
background-repeat: no-repeat;
}