我有以下代码,它简化了演示问题。menuholder div 不在表单 div 内,但它以这种方式显示。它必须在它的右边,为什么会发生这种情况?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Website</title>
<style type="text/css">
<!--
body {
font: 100%/1.4 Verdana, Arial, Helvetica, sans-serif;
margin: 0;
padding: 0;
color: #000;
background-color: #FFFFFF;
}
#header {
width: 900px;
height: 600px;
border: 2px dashed #906;
}
#website {
width: 150px;
height: 90px;
float: left;
border: 2px dashed #F00;
}
#form {
width: 300px;
height: 200px;
float: left;
border: 2px dashed #906;
}
#menuholder {
width: 220px;
height: 200px;
float: left;
border: 2px dashed #30F;
}
</style>
</head>
<body>
<div id="header">
<div id="website">
<h1><a href="#">Website</a></h1>
</div>
<div id="form">
<form action="login.php" method="POST">
<table>
<tr>
<td>
Username:
</td>
<td>
<input type="text" name="username">
</td>
</tr>
<tr>
<td>
Password:
</td>
<td>
<input type='password' name='password'>
</td>
</tr>
<table>
<p>
<input type='submit' name='submit' value='Login'>
<p>
<a href='register.php'> Register!</a>
</div>
<div id="menuholder">
<ul id="menu">
<li class="active"><a href="#">Home</a></li>
<li><a href="#">register</a></li>
<li><a href="#">about application</a></li>
<li><a href="#">demo</a></li>
<li><a href="#">help</a></li>
<li><a href="#">contact</a></li>
</ul>
</div>
</div>
</body>
</html>
在 google inspect 上,它显示 div menuholder 位于表单的 div 中。但是,在我的代码中,它不是。我能够拖放到谷歌检查中,它看起来不错。我如何修复我的代码以使其不必这样做?