我嘗試佈局我的html頁面,並獲取頂部右側的內容部分。如何將內容部分置頂?
隨着:
浮動:右; >>內容部分向右移動,但不在頁面頂部。
float:top; >>內容部分移回左側。
查看截圖插圖!
form.contact{
margin: 1% 1.5%;
padding: 5px;
border-style: solid;
width: 37.5%;
hight: auto;
}
#content{
float: right;
padding: 10px;
border:1px solid red;
width: 50%;
hight: auto;
}
form {
float: left;
margin: 1% 1.5%;
width: 63%;
}
nav{
float: left;
margin: 0 1.5%;
width: 63%;
}
footer{
float: left;
margin: 1% 1.5%;
width: 37.5%;
border-style: solid;
}
<form class="contact">
<label>Contact</label></br></br>
First name:
<input type="text" name="firstname" value="Your name please?">
<br><br>
Email:
<input type="text" name="lastname" value="Your email please?">
<br><br>
<input type="submit" value="Press the button">
</form>
<nav>
<a href = #>Just Me</a><br>
<a href = #>Portfolio</a>
</nav>
<section id = "content"><h2><strong>Content section</strong></h2></section>
<footer>
<label>Socializing</label>
</footer>
在HTML中,代碼中的第一個代碼在頁面中更高。那麼爲什麼你要把內容放在最底層呢? –
我建議你儘量避免使用'float'和'position:absolute'來進行佈局,因爲這兩者都不是。這隻會給你帶來很多麻煩。 – LGSon