How To Prevent Inline-block Divs From Wrapping?
jsFiddle demo I want the divs to: Wrap their content. Stay in their originally associated line, essentially without wrapping. Basically, the tables are stacking below each othe
Solution 1:
Add white-space: nowrap;
to your .layout
style declaration.
This will do exactly what you need: preventing the divs from wrapping.
Watch the
or run the following snippet full screen and resize it:
.layout {
white-space : nowrap; /* this does the trick */overflow : hidden; /* this prevents the grey divs from overflowing */vertical-align : top;
border-radius : 15px;
display : inline-block;
}
.layoutbacking {
border-radius : 15px;
background : #CCCCCC;
padding : 5px;
margin : 5px;
}
<divclass="layout"style="background: #222222; width: 100%"><div><divclass="layout layoutbacking"><table><tr><th>header 1</th><th>header 2</th><th>header 3</th><th>header 4</th></tr><tr><td>data 1</td><td>data 2</td><td>data 3</td><td>data 4</td></tr><tr><td>data 1</td><td>data 2</td><td>data 3</td><td>data 4</td></tr><tr><td>data 1</td><td>data 2</td><td>data 3</td><td>data 4</td></tr></table></div><divclass="layout"><divclass="layout layoutbacking"><table><tr><th>header 1</th><th>header 2</th><th>header 3</th><th>header 4</th></tr><tr><td>data 1</td><td>data 2</td><td>data 3</td><td>data 4</td></tr></table></div><br /><divclass="layout layoutbacking"><table><tr><th>header 1</th><th>header 2</th><th>header 3</th><th>header 4</th></tr><tr><td>data 1</td><td>data 2</td><td>data 3</td><td>data 4</td></tr></table></div></div></div><div><divclass="layout layoutbacking"><table><tr><th>header 1</th><th>header 2</th><th>header 3</th><th>header 4</th></tr><tr><td>data 1</td><td>data 2</td><td>data 3</td><td>data 4</td></tr></table></div><divclass="layout layoutbacking"><table><tr><th>header 1</th><th>header 2</th><th>header 3</th><th>header 4</th></tr><tr><td>data 1</td><td>data 2</td><td>data 3</td><td>data 4</td></tr></table></div>
Solution 2:
This will stop text wrapping, and keep it inline
.leftContent { float: left; }
.rightContent { overflow: hidden; }
Post a Comment for "How To Prevent Inline-block Divs From Wrapping?"