Dominick Piganell
Dominick Piganell

Reputation: 724

Dynamically change the size of a div based on content

I have a view that slides into a div using angular. My problem is, the content is dynamic and the height of that view is going to change. How can I set the height of my outer div to fit the height of the inner div? Also, my inner div has to have position: absolute in order to use the css sliding class that slides the view into place.

Also worth mentioning that if I log:

console.log($("#item-container").height());

I get 163px which is the height of one category column in the row

Outer div

<div data-ng-app="items">
    <div ng-controller="ParentController">
        <div data-ng-view class="slide-left">

        </div>
    </div>
</div>

Inner div

<div class="container" id="item-container">
    <div data-ng-repeat="c in categories">
        <div ng-class="{true: 'row'}[$index % 3 == 2]">
            <div class="col-sm-4">
                <div class="row">
                    <label>{{c.Name}}</label>
                </div>
                <a class="row" href="#!/categories/{{c.CategoryID}}">
                    <img src="/images/thumb/NoImageAvailable.jpg" class="categoryBackground" />
                </a>
            </div>
        </div>
    </div>
</div>

Upvotes: 2

Views: 2894

Answers (1)

Vivek MVK
Vivek MVK

Reputation: 1179

set

<div style="display:inline-block"></div> for all

else use css

div
{
    display:inline-block;    
}

Upvotes: 1

Related Questions