我是新來的CSS。我試圖在另一個div(#container)的右下角放置div(#inner)。 我寫了float: right;
但是當運行Html時,我看到底部的左邊的的內部div容器的角落。這是爲什麼?代碼有什麼問題?爲什麼浮動:使div浮動到左邊?
#container {
position: relative;
border: solid;
width: 70%;
height: 40%;
}
#inner {
position: absolute;
border: solid;
bottom: 0;
float: right;
width: 30%;
height: 30%;
}
<div id="container">
<div id="inner">
ABC
</div>
</div>
這裏是關於定位的一些有用的文檔,你應該看看。 http://www.barelyfitz.com/screencast/html-training/css/positioning/ –
This works。但是,你能否解釋爲什麼在使用position:absolute時爲什麼使用float沒有意義? – cookya
第二個答案在http://stackoverflow.com/questions/11333624/float-right-and-position-absolute-doesnt-work-共同揭示了爲什麼 – j08691