Search code examples
htmlcsspositioning

Expand div to contain absolutely positioned content


I have a div that contains a bunch of absolutely positioned controls. These controls are dynamically generated and I want the div to expand so it will cover all the content in both width an height. How can I do this in CSS?


Solution

  • If i understand correctly you can write like this:

    .parent{
     position:relative;
     width:100px;
     height:100px;
    }
    .dynamicDiv{
     position:absolute;
     top:0;
     bottom:0;
     left:0;
     right:0;
    }