I'm having a bit of an issue where I can't get the icons to correctly align. If I remove the section for all the icons, the Logo & title align perfectly, however when adding the icons, it causes massive issues. Sorry if this is a silly question, html is new to me!
I'm using a base HTML5 template for the design elements: HTML5UP Editorial
HTML & CSS:
/* Header */
#header {
display: -moz-flex;
display: -webkit-flex;
display: -ms-flex;
display: flex;
border-bottom: solid 5px #f56a6a;
padding: 6em 0 1em 0;
position: relative; }
#header > * {
-moz-flex: 1;
-webkit-flex: 1;
-ms-flex: 1;
flex: 1;
margin-bottom: 0; }
#header .logo {
border-bottom: 0;
color: inherit;
font-family: "Roboto Slab", serif;
font-size: 1.125em; }
#header .icons {
text-align: right; }
#media screen and (max-width: 1680px) {
#header {
padding-top: 5em; } }
#media screen and (max-width: 736px) {
#header {
padding-top: 6.5em; }
#header .logo {
font-size: 1.25em;
margin: 0; }
#header .icons {
height: 5em;
line-height: 5em;
position: absolute;
right: -0.5em;
top: 0; } }
/* Icons */
ul.icons {
cursor: default;
list-style: none;
padding-left: 0; }
ul.icons li {
display: inline-block;
padding: 0 1em 0 0; }
ul.icons li:last-child {
padding-right: 0; }
ul.icons li .icon {
color: inherit; }
ul.icons li .icon:before {
font-size: 1.25em; }
<!-- Header -->
<header id="header">
<div>
<img style="vertical-align:middle; margin-right:0.5em;"; src="images/cat-logo.png"; alt=""; width="64"; height="64";/>
<a class="logo"><strong> Oscat Pets</strong></a>
<ul class="icons">
<li><span class="label">Facebook</span></li>
<li><span class="label">Twitter</span></li>
<li><span class="label">Instagram</span></li>
<li><span class="label">Snapchat</span></li>
<li><span class="label">Medium</span></li>
</ul>
</div>
</header>
Example of Current Broken Alignment
Example of how Alignment should look
Example of Header without icons being generated
Example of HTML Inspect
You have to add below code to your css to get it working.
#header > div {
display: flex;
align-items: center;
}
#header > div > ul.icons {
margin-left: auto;
}
Try the following. I separate into two div and float the logo div to left
<style>
/* Header */
#header {
display: -moz-flex;
display: -webkit-flex;
display: -ms-flex;
display: flex;
border-bottom: solid 5px #f56a6a;
padding: 6em 0 1em 0;
position: relative;
}
#header>* {
-moz-flex: 1;
-webkit-flex: 1;
-ms-flex: 1;
flex: 1;
margin-bottom: 0;
}
#header .logo {
border-bottom: 0;
color: inherit;
font-family: "Roboto Slab", serif;
font-size: 1.125em;
}
#header .icons {
text-align: right;
}
#media screen and (max-width: 1680px) {
#header {
padding-top: 5em;
}
}
#media screen and (max-width: 736px) {
#header {
padding-top: 0;
}
#header .logo {
font-size: 1.25em;
margin: 0;
border: 0;
}
#header .icons {
height: 5em;
line-height: 5em;
right: -0.5em;
top: 0;
}
}
/* Icons */
ul.icons {
cursor: default;
list-style: none;
padding-left: 0;
}
ul.icons li {
display: inline-block;
padding: 0 1em 0 0;
}
ul.icons li:last-child {
padding-right: 0;
}
ul.icons li .icon {
color: inherit;
}
ul.icons li .icon:before {
font-size: 1.25em;
}
</style>
<!-- Header -->
<header id="header">
<div style="float: left;">
<img style="vertical-align:middle; margin-right:0.5em;" ; src="images/cat-logo.png" ; alt="" ; width="64" ; height="64" ;/>
<a class="logo"><strong> Oscat Pets</strong></a>
</div>
<div>
<ul class="icons">
<li><span class="label">Facebook</span></li>
<li><span class="label">Twitter</span></li>
<li><span class="label">Instagram</span></li>
<li><span class="label">Snapchat</span></li>
<li><span class="label">Medium</span></li>
</ul>
</div>
</header>
The template CSS you showed has some stuff in there that is either very outdated, or just pretty horrible. Because, even though it explicitly uses flexbox, it then uses oldschool positioning and such to do the things that flexbox is actually good at; weird.
Anyway, this should give you all you asked for:
/* reset header CSS to saner defaults */
#header, #header > div, #header div > a, #header .logo, #header ul.icons, #header ul.icons li, #header ul.icons li .icon {
position: static;
display: flex;
flex: 0 0 auto;
height: auto; width: auto;
line-height: normal;
padding: 0;
}
/* now define the header layout */
#header { padding: 1em; }
#header > div { width: 100%; flex-flow: row nowrap; justify-content: flex-start; align-items: center; align-content: center; gap: 1.0em; }
#header ul.icons { flex: 1 1 auto; flex-flow: row wrap; justify-content: flex-end; align-items: center; align-content: center; gap: 0.5em; }
Just place that CSS in your stylesheet (somewhere under/after the template code).
Be aware by the way, your <a ... class="logo"> element contains some odd ;s. You use ; separators inside the style="" argument, but not outside it in the HTML.
Try using position: relative instead of position: absolute.
For further understanding you could try refer this page.
#header .icons {
height: 5em;
line-height: 5em;
position: relative;
right: -0.5em;
top: 0; } }
Hi thanks all for the feedback & advice! Turns out after about 6 hours of trying lots of different things, all that was missing was a simple statement for the ul class:
style="align-self: flex-end;"
Text is now being properly aligned although the base code has changed:
<!-- Header -->
<header id="header">
<a href="index.php" class="logo"><img style="vertical-align:middle; margin-right:0.5em;" src="images/cat-logo.png" alt="" width="64" height="64" />
<strong> Oscat Pets</strong></a>
<ul class="icons" style="align-self: flex-end;">
<li><span class="label"; >Facebook</span></li>
<li><span class="label">Twitter</span></li>
<li><span class="label">Instagram</span></li>
<li><span class="label">Snapchat</span></li>
<li><span class="label">Medium</span></li>
</ul>
</header>
Ultimately, there was nothing wrong with the template, I had just used the wrong functions. Although Raxi's contributions will be taken into consideration, upon further manipulating the project!
Thanks to everyone supporting so quickly on my first post! I really appreciate this, and will be sure to engage fully on this site!
Related
This question already has answers here:
How can I align one item right with flexbox?
(5 answers)
Closed 1 year ago.
I have made a navbar, and it is supposed to replace the links with a menu icon on the right when the webpage gets below 630px wide. The problem is, my icon doesn't stay right, it stays as far left as it can go, leaving space for the margins of the hidden links (the elements themselves are gone - I set them to display: none; - but the margins are still there). I am working with the w3 schools article about responsive navbars, but only using it for the appearing icon part.
I have tried to change he display of the icon to flex, and all sorts of justification and alignment, but nothing will work. When it is set to flex it's width goes to 0 and I cant make it get wider again.
I am trying to give only the relevant code, but there is a fair amount of stuff I didn't include so feel free to ask me for more or to specify something.
.navContainer {
position: sticky;
top: 0;
margin: 0;
background-color: #ffffff;
display: flex;
justify-content: left;
align-content: flex-start;
padding-left: 10px;
padding-top: 20px;
padding-bottom: 10px;
}
.navContainer li {
list-style: none;
margin-right: 40px;
}
.navContainer a {
text-decoration: none;
color: black;
font-family: Montserrat-Regular;
font-size: 20pt;
margin: 10px;
}
.navContainer .icon {
display: none;
margin: 0;
}
.navContainer .iconImg {
max-height: 40px;
max-width: 40px;
}
#media (max-width: 630px) {
.navContainer a:not(.logoContainer, .name) {
display: none;
}
.navContainer li.icon {
float: right;
display: block;
}
}
<ul class="navContainer">
<li class="logoContainer"><img href="TriTech-Home.html" class="logo" src="https://via.placeholder.com/80"></img>
</li>
<li>TriTech</li>
<li><a class="link1" href="#">xDesk</a></li>
<li><a class="link2" href="#">Saturn Bikes</a></li>
<li href="javascript:void(0);" class="icon" onclick="myFunction()">
<img class="iconImg" src="Menu-Bars.ico">
</li>
</ul>
Don't float things. That's an outdated method, especially with flexbox. Use auto left margin on the last item.
.navContainer {
position: sticky;
top: 0;
margin: 0;
background-color: #ffffff;
display: flex;
justify-content: left;
align-content: flex-start;
padding-left: 10px;
padding-top: 20px;
padding-bottom: 10px;
}
.navContainer li {
list-style: none;
margin-right: 40px;
}
.navContainer a {
text-decoration: none;
color: black;
font-family: Montserrat-Regular;
font-size: 20pt;
margin: 10px;
}
.navContainer .icon {
display: none;
margin: 0;
}
.navContainer .iconImg {
max-height: 40px;
max-width: 40px;
}
#media (max-width: 2630px) { /* increased for demo */
.navContainer a:not(.logoContainer, .name) {
display: none;
}
.navContainer li.icon {
display: inline-block;
margin-left: auto; /* <-------------------- HERE */
}
}
<ul class="navContainer">
<li class="logoContainer"><img href="TriTech-Home.html" class="logo" src="https://via.placeholder.com/80" />
</li>
<li>TriTech</li>
<li><a class="link1" href="#">xDesk</a></li>
<li><a class="link2" href="#">Saturn Bikes</a></li>
<li href="javascript:void(0);" class="icon" onclick="myFunction()">
<img class="iconImg" src="https://via.placeholder.com/40">
</li>
</ul>
This should work
.nav-container .icon{
width: 100%;
text-align: end;
}
This is what I am trying to recreate. A basic nav.
As you can see here, there is an image next to the "ABOUT US" text, that is what I am having trouble with. How exactly can I make the img appear before the "ABOUT US" text? It always appears above it. Thanks in advance!
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
img {
max-width: 100%;
height: auto;
}
body {
font-family: "Open Sans",sans-serif;
}
.container {
max-width: 900px;
margin: 0 auto;
}
header {
padding: 2em 4em;
background-color: #121b21;
}
.nav-area {
list-style: none;
text-align: center;
}
.nav-area li {
display: inline-block;
padding: 0 1.5em;
color: #c4cbcf;
font-weight: 700;
font-size: 0.9em;
background-color: transparent;
}
<header>
<div class="container">
<nav>
<img src="header_logo.png" alt="Logo header">
<ul class="nav-area">
<li>ABOUT US</li>
<li>CONSULTING</li>
<li>SKYLIGHT</li>
<li>CONTACT</li>
</ul>
</nav>
</div>
</header>
Give a display:flex; property to nav and it will work :) Then you can adjust other CSS accordingly.
You may also set display:flex; on .nav-area, then you don't need inline-block on .nav-area li's.
.nav-area {
list-style: none;
text-align: center;
display:flex;
align-items:center;
}
CODEPEN WORKING DEMO: https://codepen.io/emmeiWhite/pen/WNGYJjq
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
img {
width:25px;
height: auto;
margin-left:1.5em;
}
body {
font-family: "Open Sans",sans-serif;
}
.container {
max-width: 900px;
margin: 0 auto;
}
header {
padding: 2em 4em;
background-color: #121b21;
}
nav{
display:flex;
align-items:center;
}
.nav-area {
list-style: none;
text-align: center;
}
.nav-area li {
display: inline-block;
padding: 0 1.5em;
color: #c4cbcf;
font-weight: 700;
font-size: 0.9em;
background-color: transparent;
}
<header>
<div class="container">
<nav>
<img src="https://picsum.photos/200" alt="Logo header">
<ul class="nav-area">
<li>ABOUT US</li>
<li>CONSULTING</li>
<li>SKYLIGHT</li>
<li>CONTACT</li>
</ul>
</nav>
</div>
</header>
I tried like this.
nav {
display: flex;
align-items: center;
justify-content: center;
}
If you want logo goes to left and nav-menu goes to right, try like this.
nav {
display: flex;
align-items: center;
justify-content: space-between;
}
Add the float attribute to the img CSS declaration to obtain the desired lay-out.
img {
max-width: 100%;
height: auto;
float: left;
}
I'm new to flexbox and CSS. I'm trying to design this navbar where the flexbox contents taking an unnecessary linebreak for a single word. Please tell me how to fix that issue.
body {
background: #000;
margin: 0;
}
.logo-title #logo {
width: 20%;
min-width: 20%;
margin: 1.5em;
position: relative;
/* left: 40%; */
}
/* =================================================================
Layout
================================================================= */
header {
background: #869189;
padding: 2em, 0;
flex: none;
}
.container {
width: 90%;
max-width: 900px;
border: 1px solid magenta;
margin: 0 auto;
}
.container-nav {
display: flex;
justify-content: space-between;
}
/* =================================================================
Navigation
================================================================= */
nav ul {
/* Turns off the bullets */
list-style: none;
padding: 0;
display: flex;
justify-content: start;
}
nav ul li {
margin: 1em;
}
nav ul li a {
text-decoration: none;
color: #FFF;
font-weight: 600;
text-transform: uppercase;
font-family: 'Poppins', sans-serif;
padding: .25em 0;
}
nav a:hover,
nav a:focus {
text-decoration: none;
color: #1AF1CE;
}
.active-page {
border-bottom: 1px solid #1AF1CE;
}
.active-page:hover {
color: #1AF1CE;
}
<header>
<div class="container container-nav">
<div class="logo-title">
<img id="logo" src="https://via.placeholder.com/150" alt="CubeWind Logo">
</div>
<nav>
<ul>
<li> Home </li>
<li> About Us </li>
<li> Our Services </li>
<li> Our Products </li>
<li> Contact Us </li>
</ul>
</nav>
</div>
<!-- / .container -->
</header>
When I changed the display of container-nav into display:flex;, the navbar is taking 2 lines to display a single word. Here, I'm attaching a screenshot of the issue. Please help me to find the cause of this.
Thanks
Screenshot
This question already has answers here:
How to disable margin-collapsing?
(12 answers)
Closed 5 years ago.
Here is the HTML code (the white gap started appearing as soon as I added h3 to the last div):
body {
margin: 0;
font-family: sans-serif;
font-weight: 400;
background-image: url("../images/rooms.jpg");
}
.container {
width: 80%;
margin: 0 auto;
}
header {
background: #343434;
}
header::after {
content: '';
display: table;
clear: both;
}
.logo {
float: left;
padding: 10px;
}
nav {
float: right;
}
nav ul {
margin: 0;
padding: 0;
list-style-type: none;
}
nav li {
padding: 0;
display: inline-block;
margin-left: 60px;
padding-top: 19px;
position: relative;
}
nav a {
text-decoration: none;
color: white;
font-size: 13px;
text-transform: uppercase;
padding: 1em 0.5em;
}
nav a:hover {
color: yellow;
}
.welcome {
width: 100%;
height: 250px;
background: #406295;
}
.welcome h3 {
text-align: center;
}
<header>
<div class="container">
<img src="images/logo.png" alt="">
<nav>
<ul>
<li>Room Types</li>
<li>Services</li>
<li>About Us</li>
</ul>
</nav>
</div>
</header>
<div class="welcome">
<h3>Welcome to</h3>
</div>
I am fairly new to web development and stackoverflow. So I am sorry for any inconveniences. Any help is appreciated. Thank you.
Set margin: 0px; on h3 tag to resolve this issue. Check updated Snippet below..
body{
margin:0;
font-family: sans-serif;
font-weight: 400;
background-image: url("../images/rooms.jpg");
}
.container{
width: 80%;
margin : 0 auto;
}
header{
background: #343434;
}
header::after{
content: '';
display: table;
clear:both;
}
.logo{
float: left;
padding:10px;
}
nav{
float:right;
}
nav ul{
margin: 0;
padding: 0;
list-style-type: none;
}
nav li{
padding: 0;
display: inline-block;
margin-left: 60px;
padding-top: 19px;
position: relative;
}
nav a{
text-decoration: none;
color:white;
font-size: 13px;
text-transform: uppercase;
padding: 1em 0.5em;
}
nav a:hover{
color:yellow;
}
.welcome{
width: 100%;
height: 250px;
background: #406295;
}
.welcome h3{
text-align: center;
margin: 0px;
}
<header>
<div class="container">
<img src="images/logo.png" alt="">
<nav>
<ul>
<li>Room Types</li>
<li>Services</li>
<li>About Us</li>
</ul>
</nav>
</div>
</header>
<div class="welcome">
<h3>Welcome to</h3>
</div>
Just remove the margin from h3 like
.welcome h3 {
text-align: center;
margin:0;
}
body {
margin: 0;
font-family: sans-serif;
font-weight: 400;
background-image: url("../images/rooms.jpg");
}
.container {
width: 80%;
margin: 0 auto;
}
header {
background: #343434;
}
header::after {
content: '';
display: table;
clear: both;
}
.logo {
float: left;
padding: 10px;
}
nav {
float: right;
}
nav ul {
margin: 0;
padding: 0;
list-style-type: none;
}
nav li {
padding: 0;
display: inline-block;
margin-left: 60px;
padding-top: 19px;
position: relative;
}
nav a {
text-decoration: none;
color: white;
font-size: 13px;
text-transform: uppercase;
padding: 1em 0.5em;
}
nav a:hover {
color: yellow;
}
.welcome {
width: 100%;
height: 250px;
background: #406295;
}
.welcome h3 {
text-align: center;
margin:0;
}
<header>
<div class="container">
<img src="images/logo.png" alt="">
<nav>
<ul>
<li>Room Types</li>
<li>Services</li>
<li>About Us</li>
</ul>
</nav>
</div>
</header>
<div class="welcome">
<h3>Welcome to</h3>
</div>
This is due to collapsing margins
Remove the margin on the h3. Replace it with padding if you want to create space between the header and maintain the background colour.
body {
margin: 0;
font-family: sans-serif;
font-weight: 400;
background-image: url("../images/rooms.jpg");
}
.container {
width: 80%;
margin: 0 auto;
}
header {
background: #343434;
}
header::after {
content: '';
display: table;
clear: both;
}
.logo {
float: left;
padding: 10px;
}
nav {
float: right;
}
nav ul {
margin: 0;
padding: 0;
list-style-type: none;
}
nav li {
padding: 0;
display: inline-block;
margin-left: 60px;
padding-top: 19px;
position: relative;
}
nav a {
text-decoration: none;
color: white;
font-size: 13px;
text-transform: uppercase;
padding: 1em 0.5em;
}
nav a:hover {
color: yellow;
}
.welcome {
width: 100%;
height: 250px;
background: #406295;
}
.welcome h3 {
text-align: center;
margin-top: 0;
}
<header>
<div class="container">
<img src="images/logo.png" alt="">
<nav>
<ul>
<li>Room Types</li>
<li>Services</li>
<li>About Us</li>
</ul>
</nav>
</div>
</header>
<div class="welcome">
<h3>Welcome to</h3>
</div>
You can try adding style="display: inline; margin:0px; padding:0px;" to your <h3> Tag.
Another way is to apply a rule of overflow: auto to the .welcome div... thus creating a new block formatting context and avoiding the collapsing margins.
Edit: Let's add a little more context. In the spec, you can read that adjoining margins will collapse under certain circumstances. In particular, the margins need to belong to block-level boxes participating in the same block formatting context.
Even though .welcome and h3 are block-level boxes in your example, neither automatically establishes a new block formatting context (meaning they participate in the same block formatting context, meaning their margins collapse). Looking at the spec again, we see that some of the ways to establish a new block formatting context is to have a float, an absolutely positioned element, or a block box with the property of overflow set to something else than visible.
That's why the suggestions regarding overflow: auto or floating one of the elements work. My understanding is that if we make .welcome establish a new block formatting context, the context it participates in is different from the one it establishes itself. Removing the margin (possibly replacing it with padding) is another way to get around the problem.
Either apply margin-top:0 for H3-Tag
or
apply a float:left for .welcome
Both will fix your issue
I am trying to add a div between the header and footer. Both are flex boxes, however the div in between (which in the end needs to be a slider) does not get positioned well. I am trying to get the header on top and the slider to fill up the remaining space of the view height. Only on the scroll it should show the footer (and eventually other div's as well). Somehow I have the feeling flex box is not working correctly..
Basically the same effect as this website: ArsThanea.
Another problem that I have when opening the JSFiddle is that the header and footer do not take the complete width of the view box, although the div does. When running the html and css in the browser using Gulp / Jekyll it works and it takes up the complete width.
header {
height: 130px;
background: white;
display: -ms-flexbox;
display: flex;
-ms-flex-align: center;
align-items: center;
-ms-flex-direction: row;
flex-direction: row;
width: 100%;
}
header .logo img {
height: 73px;
width: 146px;
padding-left: 60px;
}
header p {
text-transform: uppercase;
font-family: 'StratumNo1';
font-size: 14px;
margin: 0;
padding-left: 50px;
}
header .site-nav {
margin-left: auto;
}
header .site-nav ul {
list-style: none;
margin: 0;
}
header .site-nav ul li {
display: inline;
font-family: 'StratumNo1';
color: black;
margin: 10px;
text-transform: uppercase;
font-size: 14px;
}
header .site-nav ul li a {
text-decoration: none;
color: black;
}
header .site-nav ul li a:hover {
text-decoration: underline;
}
header .site-nav ul li a:first-child {
margin: 0px 10px 0 0;
}
header .search-form {
width: 300px;
height: 20px;
margin-left: 10px;
}
header .search-form .search-input {
width: 240px;
border-bottom: black 1px solid;
border-left: 0;
border-right: 0;
border-top: 0;
font-family: 'StratumNo1';
font-size: 14px;
}
header .search-form .search-input:focus {
outline: 0;
}
.footer-lockup {
height: 100px;
background-color: #1d1c1c;
width: 100%;
display: -ms-flexbox;
display: flex;
-ms-flex-direction: row;
flex-direction: row;
-ms-flex-pack: justify;
justify-content: space-between;
-ms-flex-align: center;
align-items: center;
position: relative;
}
.footer-lockup .copyright {
margin: 0;
color: white;
font-size: 14px;
font-family: 'Open Sans Light';
margin-left: 60px;
color: #4d4c4c;
width: auto;
}
.footer-lockup ul {
list-style: none;
margin-right: 60px;
padding: 0;
}
.footer-lockup ul li {
display: inline;
font-family: 'Open Sans Light';
font-size: 14px;
margin: 10px;
text-transform: uppercase;
}
.footer-lockup ul li:last-child {
margin-right: 0px;
}
.footer-lockup ul li a {
text-decoration: none;
color: #4d4c4c;
}
.social-logos {
position: relative;
min-width: 200px;
display: -ms-flexbox;
display: flex;
}
.social-logos .social-logo {
height: 20px;
min-width: 20px;
margin-right: 18px;
}
.social-logos .social-logo:last-child {
margin-right: 0;
}
.social-logos .social-logo .social-media {
text-align: center;
height: 20px;
cursor: pointer;
}
.social-logos .social-logo img {
height: 20px;
}
.social-logos .social-logo img.youtube {
height: 35px;
margin-top: -7px;
}
.projects-wrapper {
display: block;
background: pink;
position: absolute;
bottom: 0;
left: 0;
right: 0;
top: 130px;
}
<header>
<div class="logo">
<img src="/assets/img/YourLogo.svg" />
</div>
<p>Your Placeholder Text</p>
<nav class="site-nav">
<ul>
<li>Home
</li>
<li>About Us
</li>
<li>Services
</li>
<li>Work
</li>
<li>Contact
</li>
</ul>
</nav>
<form class="search-form">
<input placeholder="What are you looking for?" type="search" name="search-input" class="search-input" />
</form>
</header>
<div class="projects-wrapper"></div>
<footer>
<div class="footer-lockup">
<p class="copyright">© 2016 “Your Company Name” All rights reserved</p>
<div class="social-logos">
<div class="social-logo">
<div class="social-media">
<img src="/assets/img/behance-icon.svg" />
</div>
</div>
<div class="social-logo">
<div class="social-media">
<img src="/assets/img/facebook-icon.svg" />
</div>
</div>
<div class="social-logo">
<div class="social-media">
<img src="/assets/img/linkedin-icon.svg" />
</div>
</div>
<div class="social-logo">
<div class="social-media">
<img src="/assets/img/twitter-icon.svg" />
</div>
</div>
<div class="social-logo">
<div class="social-media">
<img src="/assets/img/youtube-icon.svg" class="youtube" />
</div>
</div>
</div>
<ul>
<li>Home
</li>
<li>About Us
</li>
<li>Services
</li>
<li>Work
</li>
<li>Contact
</li>
</ul>
</footer>
DEMO: JSFiddle
Taking a look at your Fiddle, there are many improvements you can make to your markup & CSS, but coming to your issue first, the reason why its not sliding down as expected is this :
position: absolute
you added this to your main div which should go in between .projects-wrapper. First thing I would say is make this a flex as well instead of block element.
Secondly, add a wrapper to your entire project body & Make that flex. like so
<div class="wrapper"> //this should be flex
<header>..</header> //this "could" be flex depending on its contents
<div class="projects-wrapper"></div>
<footer>...</footer> //this "could" be flex depending on its contents
</div>
let me know if you are facing any other problems
I made code for You, please have a look, and tell mi is it good for You.
fiddle
I use calc() to do that
Use 100vh to get the 100% view-port height and subtract the height of header and footer.
min-height: calc(100vh - 50px);
where 50px is the height of header+footer.
partial support for ie