我有兩個div的:如何定位低於另一個DIV DIV
<div><label for="1">Some really loooong text... Which breaks the second div. Which then appears shifted to the right.</label><input type="text" id="1" name"1"></div>
<div><label for="2">Shifted.</label><input type="text" id="2" name"2">
我用下面的CSS浮動左輸入文本字段的標籤:
label{
width:200px;
float:left;
}
的第二個div轉移到而不是出現在第一個下面。它應該與第一個左側對齊。
這裏是例子:http://jsfiddle.net/qh37Y/
現在,如果我插入明確:兩者; div工作,但這是最佳做法?
.clearer {
clear:both;
}
<div class="clearer"><label for="2">Shifted.</label><input type="text" id="2" name"2">
在這裏看到:http://jsfiddle.net/ywUx6/
只要你知道,這是正確的答案。 – dbkaplun
哦,'overflow:auto'也是可以接受的。 –
我不得不添加'width:100%'來讓它在我的情況下工作(在FF和Chrome中) – koppor