简体   繁体   English

显示一个 <div> 右下角无位置:绝对

[英]Show a <div> at bottom right corner without position: absolute

I have a <div> like below 我有一个像下面的<div>

<div style="right:0px;bottom:0px;position:absolute;">

</div>

When my mobile site is opened in portrait mode, this div is displayed correctly at the bottom right corner. 以纵向模式打开我的移动网站时,此div正确显示在右下角。 But, when opened in landscape mode it is displayed at corner and overlaps the elements already present. 但是,当以横向模式打开时,它将显示在角落,并且与已经存在的元素重叠。

I want this div to be at the bottom of all elements at the bottom right corner of the page. 我希望此div位于页面右下角所有元素的底部。 How do I do it? 我该怎么做?

I would suggest to use flexbox - but it could need to reorganise a little your css code 我建议使用flexbox-但可能需要重新组织一些CSS代码

 .page { display: flex; flex-direction: column; justify-content: flex-start; align-items: center; height:100vh; } .element { height: 10px; width: 80%; border: 1px solid #000; padding: 20px 0; } .element.bottom { margin-top: auto; background: red; } 
 <div class="page"> <div class="element"> </div> <div class="element"> </div> <div class="element"> </div> <div class="element bottom"> </div> </div> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM