steeve
steeve

Reputation: 699

Aligning side by side in a modal

Here is my fiddle,

HTML

<div id="wrapper">
    <div class="notes">One</div>
    <div class="notes">two</div>
    <div class="notes">three</div>
    <div class="notes">four</div>
</div>

CSS

#wrapper {
    width: 300px;
    overflow-x: scroll;
    overflow-y: scroll;
    border: 1px solid black;
}
.notes {
    color: red;
    border: 1px solid green;
    margin: 5px;
    width: 200px;
    height: 150px;
    display: inline-block;
}

I have a wrapper div which has 300px width.

The inner divs are generated dynamically based on the server request and has the width of 200px each.

Now i need to set side by side in the wrapper and when it reach 300px it needs to be displayed in a scrolled mode..

Seems i have some issues in my code. Pls help...

Upvotes: 0

Views: 319

Answers (1)

Hashem Qolami
Hashem Qolami

Reputation: 99474

You could give white-space: nowrap; to the wrapper, then reset it to white-space: normal; for each item.

Example Here

#wrapper { white-space: nowrap; }
.notes { white-space: normal; }

You might also want to remove the white-space between inline block elements. There are several approaches to achieve that, one of them could be setting font-size: 0 to the parent, then resetting it to font-size: 16px on the children.

Updated Example

Upvotes: 2

Related Questions