简体   繁体   English

如何将绝对定位的元素推到底部而不重叠

[英]How to push the absolute positioned element to the bottom without overlapping

I have a container in which the text can go larger, but need to always make sure that the child element with absolute positioned element should always stick to the bottom of the container and should not overlap with the top container content. 我有一个可以在其中放大文本的容器,但需要始终确保具有绝对定位元素的子元素应始终粘贴在容器底部,并且不应与容器顶部内容重叠。

found many examples but all are developed using flexbox, need to support internet explorer 9 找到了很多示例,但是所有示例都是使用flexbox开发的,需要支持Internet Explorer 9

this is what tried. 这是尝试过的。

 .container{ max-width: 940px; margin: 20px auto; border: 1px solid red; } .table{ display: table; width: 100%; } .table-cell{ display: table-cell; position: relative; height: 260px; } .absolute{ position: absolute; bottom: 0; } 
 <div class="container"> <div class="table"> <div class="table-cell"> <div> This content can go very bring, push the absoulte position element to the bottom always without overlapping parent content. This content can go very bring, push the absoulte position element to the bottom always without overlapping parent content. This content can go very bring, push the absoulte position element to the bottom always without overlapping parent content. This content can go very bring, push the absoulte position element to the bottom always without overlapping parent content. This content can go very bring, push the absoulte position element to the bottom always without overlapping parent content. This content can go very bring, push the absoulte position element to the bottom always without overlapping parent content. This content can go very bring, push the absoulte position element to the bottom always without overlapping parent content. This content can go very bring, push the absoulte position element to the bottom always without overlapping parent content. This content can go very bring, push the absoulte position element to the bottom always without overlapping parent content. This content can go very bring, push the absoulte position element to the bottom always without overlapping parent content. This content can go very bring, push the absoulte position element to the bottom always without overlapping parent content. This content can go very bring, push the absoulte position element to the bottom always without overlapping parent content. This content can go very bring, push the absoulte position element to the bottom always without overlapping parent content. This content can go very bring, push the absoulte position element to the bottom always without overlapping parent content. </div> <div class="absolute"> asdasd </div> </div> </div> </div> 

As mentioned in the comment, you can always add padding-bottom (to your long text div) relative to your .absolute content height. 如评论中所述,您始终可以相对于.absolute内容高度添加padding-bottom(到您的长文本div)。 Since you tagged jQuery, I recommend adding it dynamically. 由于您标记了jQuery,因此我建议动态添加它。 Set your padding-bottom using this value: jQuery('.absolute').height() 使用以下值设置padding-bottomjQuery('.absolute').height()

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

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