Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Expand div horizontally not vertically

Tags:

html

css

I have a div with

display:inline-block;
postion:relative;

inside a div with

display:block;
width:348px;
overflow:hidden;

When the contents of the inner div overflow, I want them to expand horizontally, not vertically. The contents of the inner div consists of thumbnails of photos

like image 922
sanchitkhanna26 Avatar asked Mar 08 '13 12:03

sanchitkhanna26


1 Answers

You just need to set white-space: nowrap on either of the divs (the property is inherited). (Source)

Sidenote: The inner div is not necessary for this to work.

Demo: JSFiddle

HTML

<div class="container">
    <div>
        <!-- Thumbnails -->
    </div>
</div>

CSS

.container {
    display: block;
    width: 348px;
    overflow: hidden;
    white-space: nowrap;
}

.container div {
    position: relative;
    display: inline-block;
}
like image 200
thgaskell Avatar answered Sep 27 '22 22:09

thgaskell