Doan Cuong
Doan Cuong

Reputation: 2614

div width fit to its content and overflow its parent

Take a look at this html:

<div class="parent_container">
    <div class="container">
        <div class="item">
            <img src="http://mountainguides.com/wordpress/wp-content/uploads/2010/11/Illinizas-photo-ty-gimenez.jpg"/>
        </div>
        <div class="item">
            <img src="http://mountainguides.com/wordpress/wp-content/uploads/2010/11/IMG_0700.jpg"/>
        </div>
    </div>
</div>

I'm trying to make div: item line up in one row and div: container width will auto resize to fit its children. I don't know the number of div: item so I can't specific width for div: container.

Here is a jsfiddle: http://jsfiddle.net/trongcuong1710/cDqSj/4/

Upvotes: 0

Views: 58

Answers (1)

Sergio
Sergio

Reputation: 28845

.container {
position:absolute;
float:left;
width: 100%;
min-width:1px;
}

Is this (jsfiddle.net/cDqSj/7/) what you want?

Upvotes: 1

Related Questions