我正在用側邊欄創建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