Make a DIV push the rest of the content down

Asked

Viewed 1,295 times

5

Everything all right? I have a question here, but I wanted to understand, not just ask people to do what I need to do. I will try to explain: I have a button to add lines of text. Below this button, I have a 600px high DIV where these lines will be created each time they are added by the button.

Underneath this DIV, there’s another one I just put to the test. What I want to understand how to do is: I need that as soon as the number of lines created within the DIV exceeds 600px, the height follows the creation of the lines and push the other div down. This is done through positioning, isn’t it? Or I’m wrong and it takes more things?

Thank you very much folks! As I said, it is a question of concept! :)

1 answer

7


Hello. If you have not made any change of position, the lower div will automatically position itself according to the height set by the top. What happens is that you probably delimited the exact size of the top div. Something like:height: 600px. Instead of using this property, you should use the min-height. Thus, the "default" element will be 600px high but, if you add more content, it will automatically suit, pushing the other div down.

.div-superior{
  min-height: 600px;
}
  • Lucas, thank you so much man! You got what I needed to understand right. I put it that way and it worked right! Actually, the focus of my study is javascript, but it came up and I didn’t really know what to do. I tried to change position on you, I searched and I couldn’t find it. Thank you very much! !

  • Hug and nothing. Good studies :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.