In the middle (not banner or footer) section of my page, I have two elements: classed as left-container and right-container.
I want to fill the left-container with many columns of a specific width, and have them overflow to the left, such that the page loads to show their right-most element and the user must scroll left to see the others.
How is this possible with flexbox?
Here's my code:
@import url("https://fonts.googleapis.com/css2?family=Heebo:wght@600&display=swap");
body {
margin: 0;
padding: 0;
}
.page-container {
display: flex;
flex-direction: column;
height: 100vh;
background-color: teal;
align-items: stretch;
flex-direction: column;
}
.banner {
background-color: lightcyan;
position: relative;
width: 100%;
height: 80px;
}
.banner-title {
font-family: "Heebo";
font-weight: 600;
font-size: 40px;
padding: 10px;
}
.footer {
width: 100%;
background-color: thistle;
height: 30px;
}
.body-container {
background-color: lightcyan;
width: 100vw;
height: 100vh;
display: flex;
justify-content: flex-end;
}
.left-container {
background-color: greenyellow;
width: 100vw;
display: flex;
justify-content: flex-end;
flex-wrap: nowrap;
overflow: auto;
}
.right-container {
background-color: tomato;
width: 350px;
height: 100%;
}
.column-container {
background-color: red;
width: 150px;
margin: 5px;
display: flex;
flex-direction: column;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<div class="page-container">
<div class="banner">
<div class="banner-title">Title</div>
</div>
<div class="body-container">
<div class="left-container">
<div class="column-container"></div>
<div class="column-container"></div>
<div class="column-container"></div>
<div class="column-container"></div>
<div class="column-container"></div>
<div class="column-container"></div>
<div class="column-container"></div>
<div class="column-container"></div>
</div>
<div class="right-container"></div>
</div>
<div class="footer">Footer</div>
</div>
<script src="./stopwatch.js"></script>
</body>
</html>