我正在用侧边栏创建html布局。但是我的标题和内容在下方出现,而不是旁边的。页面内容出现在侧边栏下
.container { position:relative; padding:10px; top:0px; right: 0; left: 0; height: 1200px;}
#sidebar {
position:relative;
top:0; bottom:0; left:0;
width:200px;
height: 1000px;
background: gray;
}
#header { border:1px solid #000; height:300px;
padding:10px; margin-left: 200px;
}
#content { border:1px solid #000; height:700px; margin-left: 200px;;
padding:10px;
}
<div class="container">
<div id="sidebar">
<a href="#"> Link1 </a>
</div>
<div id="header">
<h2 class="title">Title</h2>
<h3>Header content</h3>
</div>
<div id="content">
<center>
<p>Hello</p>
</center>
</div>
</div>
\t \t
感谢
你试过只是改变 '的位置是:相对的;'到'位置:绝对;'?就像在这个小提琴:https://jsfiddle.net/khs8j3gu/ – Rubenxfd
@Rubenxfd这已经最好......但每个div的内容然后不与边界排队....它都在它下面.. –
你究竟是什么意思?边框与侧边栏略有不成比例?您可以通过添加边距来解决此问题。也许这是你需要的? https://jsfiddle.net/khs8j3gu/2/ – Rubenxfd