I’m trying to get two divs always side-by-side even when the container is too small. I want to hide the overflow of the righthand div, but can’t seem to achieve this. When I resize the browser to make the scrollbar appear on the body, the right-hand div moves down underneath.
Here’s my HTML so far:
<!DOCTYPE html>
<html>
<head>
<style>
body {
margin: 0;
padding: 0;
min-width: 800px; overflow: auto;
}
span { display: block; }
#div-outer {
width: 95%;
height: 300px;
padding: 2px;
border: 4px solid green;
display: block;
}
#div-box-left {
border: 3px solid black;
width: 250px;
height: 250px;
float: left;
display: inline-block;
}
#div-box-right {
border: 3px solid red;
height: 250px;
margin-left: 10px;
overflow: hidden;
float: left;
display: inline-block;
}
#tbl {
background: yellow;
border: 3px solid blue;
}
</style>
</head>
<body>
<span>Wide div to contains two divs</span>
<div id="div-outer">
<div id="div-box-left">
Left div with a width of 250px
</div>
<div id="div-box-right">
<span>This contains a table but is too wide to fix - I want the table's overflow hidden</span>
<table id="tbl">
<tr>
<td>Column</td>
<td>Column</td>
<td>Column</td>
<td>Column</td>
<td>Column</td>
<td>Column</td>
<td>Column</td>
<td>Column</td>
<td>Column</td>
<td>Column</td>
<td>Column</td>
<td>Column</td>
<td>Column</td>
<td>Column</td>
<td>Column</td>
<td>Column</td>
<td>Column</td>
</tr>
</table>
</div>
</div>
</body>
</html>
You may need another
div, alternatively you could apply the style for.outeron the body:Simplified example
CSS:
HTML:
Your example, fixed.