Desired output:
- The red div (
table-container) will display vertical / horizontal scroll bars around the table it contains. - No scroll bars will appear on the browser window or parent element.
Actual output:
Horizontal and vertical scroll bars are displayed on the browser window as well as the
table-containerdiv.Height of the table is not constrained.
Solutions I would like to avoid:
Placing a fixed height/width on
table-container. Note thatbodyis constrained to 100vh/vw.Attempting to modify the table i.e. using something like
table-layout.
Edit: Table height and width are specified in this example html only to illustrate the problem. In my application I have no control over the size of the table and it is quite large.
<html>
<head>
<style>
body, html {
height:100vh;
width:100vw;
max-height:100vh;
max-width:100vw;
display:flex;
flex:1;
margin:0;
padding:0;
}
footer {
display:flex;
height: 10vh;
min-height: 10vh;
background-color:#666666;
}
.page
{
display:flex;
flex:1 1 auto;
flex-direction:row;
}
.side-nav {
display: flex;
flex:0 1 auto;
flex-flow: column;
width:20vw;
min-width:20vw;
height:100vh;
min-height:100vh;
background-color:#99ccff;
}
.content {
display: flex;
flex-direction:column;
flex:1 1 auto;
background-color:#cccccc;
}
.col-layout {
display:flex;
flex:1 1 auto;
flex-direction:column;
}
.table-container {
display:flex;
flex-direction:column;
overflow-x:scroll;
overflow-y:scroll;
margin:3%;
background-color:red;
width:90%;
max-width:90%;
height:90%;
max-height:90%;
}
table {
margin:3%;
width:1500px;
height:2000px;
background-color:#3399ff;
}
</style>
</head>
<body>
<div class="page">
<div class="side-nav">
<label>Side Nav</label>
</div>
<div class="col-layout">
<div class="content">
<label>Content</label>
<label>The red div should have vertical and horizontal scroll bars - no vertical or horizontal scroll bars should appear on the browser window.</label>
<div class="table-container">
<table>
<tr><td>key</td><td>value</td></tr>
</table>
</div>
</div>
<footer>
<label>Footer</label>
</footer>
</div>
</div>
</body>
</html>
