I have a simple layout: header + sidebar + form. I'm trying to stick the sidebar to the left, while the form is near the center/wherever. Sidebar and form are inside a wrapper content
div with display: flex; flex-direction: row; justify-content:center
. I tried setting margin-left:0
on the sidebar div
, but it didn't work:
JsFidlde: https://jsfiddle.net/2qzmkwaj/
Current output:
Need to achieve:
/*
Positioning
*/
#app {
display: flex;
flex-direction: column;
justify-items: center;
}
#navbar {
display: flex;
justify-content: flex-end;
}
#navbar .button {
margin-right: 20px;
background-color: green;
}
#header {
background-color: dimgray;
display: flex;
flex-direction: column;
align-items: flex-end;
}
#logo-wrapper {
display: flex;
justify-content: center;
flex-direction: row;
width: 100%;
}
#content {
display: flex;
justify-content: center;
border: 1px solid red;
height: 100%;
}
#sidebar {
margin-left: 0 !important;
border: 1px solid black;
height: 100%;
}
#content form {
margin-left: 0;
border: 1px solid white;
height: 100%;
}
/*
Colors
*/
#sidebar {
background-color: yellow;
}
body {
background-color: chocolate;
}
#content textarea {
background-color: black;
color: silver;
}
<div id="app">
<div id="header">
<div id="navbar">
<div class="button">
Button
</div>
<div class="button">
Button
</div>
<div class="button">
Button
</div>
</div>
<div id="logo-wrapper">
<div id="logo">
<img width="100" src="https://i.pinimg.com/originals/37/25/de/3725deaa9c536997aaa2f4956c2045b3.jpg" />
</div>
</div>
</div>
<div id="content">
<div id="sidebar">
<div class="sidebar-option">
Option
</div>
<div class="sidebar-option">
Option
</div>
<div class="sidebar-option">
Option
</div>
</div>
<form>
<textarea></textarea>
</form>
</div>
</div>
I also need to make the sidebar take all of the page height. I tried height: 100%
on both the content
and sidebar
divs, but it didn't work.