Lijo Lijo - 6 months ago 6x
Javascript Question

Parent Div does not adjust height when adding div dynamically

I am adding divs dynamically as shown in

The parent #mainHolder div is not increasing its width when child elements are added – as a result the children breaks the parent div. How can we overcome this by adjusting the parent div height?

enter image description here


Add overflow:auto

    width: 400px;
    border-top: 3px solid orange;
    border-bottom: 3px solid red;
    border-left: 3px solid purple;
    border-right: 3px solid pink;
    height:auto; overflow:auto

Demo here