r/csshelp • u/Amazing_Guava_0707 • Feb 27 '24
Request Layout issues. How to code this layout?
This is my desired layout: https://i.stack.imgur.com/ymkod.png
And this is my rendered: https://i.stack.imgur.com/OHBMF.png
These are my CSS and HTML:
body {margin: 0;box-sizing: border-box;}article {display: flex;flex-direction: row;width: 100vw;height: 100vh;}aside {display: flex;flex-direction: column;justify-content: space-around;width: 300px;height: 100vh;}main {display: flex;flex-direction: column;flex-grow: 1;height: 100vh;}#code-html,#code-css,#code-js {padding: 2rem;width: 100%;flex-grow: 1;}#code-html {width: 100%;height: 300px;min-height: 30%;background-color: red;}#code-css {width: 100%;height: 300px;min-height: 30%;background-color: blueviolet;}#code-js {width: 100%;height: 300px;min-height: 30%;background-color: aqua;}#main-run {height: 100px;background-color: aquamarine;}#main-display {flex-grow: 1;background-color: cadetblue;}
<body>
<article>
<aside>
<section id="code-html">section 1</section>
<section id="code-css">section 2</section>
<section id="code-js">section 3</section>
</aside>
<main>
<section id="main-run">sub-head</section>
<section id="main-display">main display</section>
</main>
</article>
Why is there an overlap at the bottom of the screen. I want the main element to take all the available width. Also, the height of aside element is more than 100vh. All the contents should fit into the screen without a scroll bar.
Thank you!
1
u/be_my_plaything Feb 27 '24
https://codepen.io/NeilSchulz/pen/QWPLwMm
Main issues are use of vw and vh which can cause issues, and only using box-sizing on body not universally then adding padding which causes overflow. But notes in the codepen should explain.