以下のコードは、W3CSchool の例からのものです。
<!DOCTYPE html>
<html>
<body>
<div id="container" style="width:500px">
<div id="header" style="background-color:#FFA500;">
<h1 style="margin-bottom:0;">Main Title of Web Page</h1></div>
<div id="menu" style="background-color:#FFD700;height:200px;width:20%;float:left;">
<b>Menu</b><br>
HTML<br>
CSS<br>
JavaScript</div>
<div id="content" style="background-color:#EEEEEE;height:200px;width:80%;">
Content goes here</div>
<div id="footer" style="background-color:#FFA500;text-align:center;">
Copyright © W3Schools.com</div>
</div>
</body>
</html>
コードをコピーして、以下のエディターに貼り付けることができます: http://www.w3schools.com/html/tryit.asp?filename=tryhtml_layout_divs
「メニュー」の幅を 20%、「コンテンツ」の幅を 80% に指定しましたが、「コンテンツ」の右側に空白領域があるのはなぜですか?
「コンテンツ」の CSS スタイルに「float:left」を追加した場合にのみ、適切に配置されます。なぜそのような振る舞いをするのか理解できません。誰でも説明できますか?
手伝ってくれてありがとう。