我試圖讓第二個文本框與第一個文本框相對。正確的是在右下方。CSS將輸入(文本框)彼此對齊
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<div>
<h2>Top</h2>
<div>
<h2>TextBox 1</h2>
<div>
<input type="text" />
</div>
</div>
<div style="float:right;">
<h2>textbox2</h2>
<div>
<input type="text" />
</div>
</div>
</div>
</body>
</html>
不要忘記添加一個「clearfix」級,並將其應用於包裝父div,以便樣式將按預期應用。 .clearfix:在{ 內容:「」;/*舊版瀏覽器不支持空白內容*/ 知名度:隱藏; display:block; 身高:0; 明確:均; } – KnowHowSolutions