簡體   English   中英

將內部div移動到外部父div的右下角

[英]Moving inner div to the bottom-right corner of the outer parent div

我希望我的內部div位於外部div的右下角,使用float: right ,但由於某種原因,它會留在左下角。 我究竟做錯了什么?

 #outer { width:100%; height:20%; border: 1px solid black; position: absolute; } #inner { width: 50px height: 50px; border: 1px solid red; position: absolute; float: right; bottom: 0; } 
 <div id = 'outer'> <div id = 'inner'> bottom-right corner; </div> </div> 

添加right: 0代替。

如果元素絕對定位,浮動元素將不會對它產生任何影響。

 #outer { width: 100%; height: 20%; border: 1px solid black; position: absolute; } #inner { width: 50px height: 50px; border: 1px solid red; position: absolute; bottom: 0; right: 0; } 
 <div id='outer'> <div id='inner'> bottom-right corner; </div> </div> 

更改外部div的css屬性如下:

#inner {
     width: 50px
     height: 50px;
     border: 1px solid red;
     position: absolute;
     bottom: 0; 
     right:0
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM