Dynamically increasing the content of the div

Asked

Viewed 921 times

2

I have 3 div’s and div2 should have dynamic content (growing as the content is inserted in it), div1 should follow the growth of div2. How can I do that?

    <div id="divPrincipal">
        <div id="div1" style="width:20%; background-color:gray;"></div>
        <div id="div2" style="width:80%"> Conteúdo dinâmico ... </div>
    </div>

Does anyone have any idea?

  • Are you using any framework?

  • In the case indicated by Renan the div occupies the remaining bottom, already in this case, the objective is to follow laterally. One grows on one side and the other accompanies the other.

1 answer

3


This is automatic, it took me a while to learn. The main div must be Absolute or Relative

position:relative;

or

position:absolute;

and div 2 must be relative and the whole content within must be relative. If the fault does not work can be in the elements next to the main div that should be relative. Avoid using width or height by percentage but you can use width: 100% in both div if you want the length of div 1 to be equal to that of div 2 and div 2 to be below div 1. Don’t forget to use max-width and max-height with overflow: auto

  • It was the overflow that was missing, thank you.

Browser other questions tagged

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