いじくり回した後、絶対配置がドキュメントフローから要素を削除することを思い出しました。絶対配置された要素に依存して、他の要素に影響を与えることはできません。コンテンツの高さがわからないため、margin-top を使用することは明らかにオプションではありません。
だから私はこれを思いつきました:基本的にフロートで通常のレイアウトを行い、次に相対位置を使用してアイテムを必要な場所に移動します。このように、要素は引き続きドキュメント フローに影響を与えますが、位置を完全に制御できるようになりました。これがまさに相対配置の目的です。要素の位置を完全に制御したいが、要素がレイアウトに通常どおり影響するようにしたい場合。
<html>
<head>
<style>
body {
text-align:center;
}
#container {
position:relative;
margin:0 auto;
width: 1000px;
text-align:left;
}
#header {
position:relative;
top:0px;
left:0px;
width:1000px;
height: 100px;
border:solid 1px #000;
}
#sidebar {
position:relative;
top:10px;
left:0px;
width:300px;
height: 500px; /* for demo */
float:left;
margin-bottom: 20px;
border:solid 1px #000;
}
#main {
position:relative;
top:10px;
left:310px;
width:690px;
height: 200px; /* for demo */
margin-bottom:20px;
border:solid 1px #000;
}
#footer {
margin:0 auto;
top:20px;
width: 1000px;
text-align:left;
height: 100px;
clear:both;
border:solid 1px #000;
}
</style>
</head>
<body>
<div id="container"> <!-- Holds all the content except the footer -->
<div id="header">Header content here</div>
<div id="sidebar">Sidebar content here</div>
<div id="main">Main content here</div>
</div>
<div id="footer">Footer content here</div>
</body>
</html>