DIV / CSS的标准是什么?为什么当我<form>
<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>Untitled Document</title>
<style type="text/css">
.header {
background-color: #e3f2ff;
width: 980px;
border: 1px solid #666;
}
.main {
width: 980px;
border: 1px solid #666;
height: 300px;
}
.left {
background-color: #FFC;
float: left;
width: 200px;
height: 300px;
}
.cen {
background-color: #0FF;
float: left;
height: 300px;
width: 578px;
border-right-width: 1px;
border-left-width: 1px;
border-right-style: solid;
border-left-style: solid;
border-right-color: #666;
border-left-color: #666;
}
.footer {
background-color: #e3f2ff;
width: 980px;
border: 1px solid #666;
}
</style>
</head>
<body>
<center>
<div class="header">Header</div>
<div class="main">
<div class="left"></div>
<form action="home.php" method="post">
Username:<input type="text" name="username"/>
Password:<input type="password" name="password">
<input type="submit" name="smbit" value="Login">
</form>
<a href="register.php">Not Register?</a>
<div class="cen"></div>
<div class="left"></div>
</div>
<div class="footer">
Copy Right
</div>
</center>
</body>
</html>
答案 0 :(得分:1)
为了得到正确答案,您可以更明确地了解自己想要的位置和位置。 Wayne的答案很好,如果你想要它在正确的div中,那么把它放在第二个左div中。如果你把它放在那个div之外,你不能期望一个元素显示在那个div中。
<center>
<div class="header">Header</div>
<div class="main">
<div class="left"></div>
<div class="cen"></div>
<div class="left">
<form action="home.php" method="post">
Username:<input type="text" name="username"/>
Password:<input type="password" name="password">
<input type="submit" name="smbit" value="Login">
</form>
<a href="register.php">Not Register?</a></div>
</div>
<div class="footer">
Copy Right
</div>
</center>