我想要一個div浮動在我的input
旁邊,但是它在上面浮動,我不知道爲什麼。就好像div被設置爲使用絕對定位一樣。我想我可能只是忽略了一些愚蠢的東西,但它是什麼?爲什麼這個div掩蓋了這個按鈕?
HTML:
<input type="file" id="files" name="file" />
<div id="progress_bar"><div class="percent">0%</div></div>
CSS:
input { float: left;}
#progress_bar {
margin: 10px 0;
padding: 3px;
border: 1px solid #000;
font-size: 14px;
//clear: both;
opacity: 0;
-moz-transition: opacity 1s linear;
-o-transition: opacity 1s linear;
-webkit-transition: opacity 1s linear;
}
#progress_bar.loading {
opacity: 1.0;
}
#progress_bar .percent {
background-color: #99ccff;
height: auto;
width: 0;
}
我這裏有一個例子: http://jsfiddle.net/sWrvU/ 這是根據讀取的文件演示上HTML5ROCKS http://www.html5rocks.com/en/tutorials/file/dndfiles/
取消註釋clear:both
看演示實際上工作(即你可以按下按鈕,因爲沒有一個div之上),但顯然div仍然沒有在輸入旁邊浮動。
我認爲它是浮動在頂部,因爲它阻止按鈕按下。 – Joe
是的,看着互動,「漂浮在上面」是有道理的,但是在CSS的「漂浮」意義上它被交換了;) – cjc343