Hello! There is a container in which there is a block with the text .text and a button .btn . For reasons for which I will not go into details, I have to do the .btn button with absolute positioning, but it should behave in the same way as with position: static; - i.e. positioned after the text and shifted depending on the height of the .text block.
From here I have a question: is it possible to track the height of a .text block using js/jQuery both during loading and when resizing it, and assign the value of this height + indent, say, to 10px for the value of the top property of the .btn button?
.wrapper { position: relative; max-width: 450px; margin: 50px auto; padding: 15px; box-shadow: 0 0 5px 0 rgba(0,0,0,.5); } .text { margin-bottom: 30px; } .btn { position: absolute; top: 0; width: calc(100% - 30px); display: flex; justify-content: center; align-items: center; height: 30px; text-decoration: none; background: rgba(0,0,0,.5); color: #fff; } <div class="wrapper"> <div class="text"> Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. </div> <a href="#close" class="btn">Some btn</a> </div>
top: 0withmargin-top: -25px;? - Qwertiy ♦top:0;andleft: 0;relative to the parent. - Igor