简体   繁体   中英

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...

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM