我想要一个 div 漂浮在我的旁边,input
但它却漂浮在它上面,我不知道为什么。就好像 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 仍然没有浮动在输入旁边。