我正在尝试使id =“contact_details”的部分出现在id =“form”旁边。它适用于我的一个CSS样式表,但不适用于其他样式表。我不知道我要去哪里错了......我试过它,没有相对位置,不同宽度等。为什么我的“float:left;”不行?
您的帮助将非常感谢!欢呼声中,玛丽
#wrapper {
width: 989px;
margin: 0 auto 0;
position: relative;
background-color: gray;
}
#contact_details {
float: left;
position: relative;
width: 350px;
padding-top: 30px;
padding-left: 30px;
padding-right: 30px;
background-color: blue;
}
#form {
float: left;
position: relative;
width: 450px;
padding-top: 30px;
padding-right: 30px;
background-color: red;
}
#form_table {
padding-left: 0px;
padding-right: 0px;
}
<body>
<div id="wrapper">
<header></header>
<nav></nav>
<section id="contact_details">
<h1>Contact Details</h1>
<br>
<h3>Physical Address</h3>
<p><em>There and Back Travel</em></p>
<p>Travel House Level 1</p>
<p>Travel Line North</p>
<p>Waikanae</p>
<p>New Zealand</p>
</section>
<aside id="form">
<h1></h1>
<form name="user_details">
<table id="form_table">
<tr>
<td class="form_cell"><label for="first_name">First Name:</label></td>
<td class="form_cell"><input type="text" name="first_name"></td>
</tr>
<tr>
<td class="form_cell"><label for="surname">Surname:</label></td>
<td class="form_cell"><input type="text" name="surname"></td>
</tr>
<tr>
<td>Preferred tour types:</td>
<td>
<input type="checkbox" name="adventure">Adventure<br>
<input type="checkbox" name="beach">Beach<br>
<input type="checkbox" name="leisure">Leisure<br>
</td>
</tr>
</table>
<input type="submit"><input type=reset>
</form>
</aside>
<footer></footer>
</div>
</body>
请运行您的代码段,你会看到它工作得很好。 –