Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ayodejioju/ec8e827b717c6ea522dc4008f716bae0 to your computer and use it in GitHub Desktop.
Save ayodejioju/ec8e827b717c6ea522dc4008f716bae0 to your computer and use it in GitHub Desktop.
How to Build a Full-Screen Responsive Page With Flexbox (Animated)
<div class="wrapper">
<header class="page-header">
<nav>
<h2 class="logo">LOGO</h2>
<ul>
<li>
<a href="">work</a>
</li>
<li>
<a href="">services</a>
</li>
<li>
<a href="">team</a>
</li>
<li>
<a href="">careers</a>
</li>
</ul>
<button class="cta-contact">get in touch</button>
</nav>
</header>
<main class="page-main">
<div>
<div class="text-wrapper">
<h1>We are here to help you</h1>
</div>
<div class="text-wrapper p-wrapper">
<p>One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin.</p>
</div>
<div class="text-wrapper p-wrapper">
<p>It wasn't a dream. His room, a proper human.</p>
</div>
</div>
</main>
<footer class="page-footer">
<small>© Copyright 2018. All rights reserved.</small>
<ul>
<li>
<a href="" target="_blank">
<i class="icon ion-logo-facebook"></i>
</a>
</li>
<li>
<a href="" target="_blank">
<i class="icon ion-logo-twitter"></i>
</a>
</li>
<li>
<a href="" target="_blank">
<i class="icon ion-logo-linkedin"></i>
</a>
</li>
<li>
<a href="" target="_blank">
<i class="icon ion-logo-github"></i>
</a>
</li>
</ul>
</footer>
</div>
window.addEventListener("load", () => {
document.querySelector("body").classList.add("loaded");
});
@import url("https://fonts.googleapis.com/css?family=Dosis:400,700");
:root {
--main-white-color: #f2f2f2;
--main-black-color: black;
--main-purple-color: #9e89b8;
}
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
button {
background: none;
outline: none;
cursor: pointer;
}
ul {
list-style: none;
}
a {
text-decoration: none;
color: inherit;
}
body {
font: 16px/1.5 "Dosis", sans-serif;
background: var(--main-white-color);
/*IE FIX*/
/*display: flex;
flex-direction: column;*/
}
/* CONTAINER
–––––––––––––––––––––––––––––––––––––––––––––––––– */
.wrapper {
display: flex;
flex-direction: column;
min-height: 100vh;
}
.wrapper > * {
padding: 20px;
}
/* HEADER
–––––––––––––––––––––––––––––––––––––––––––––––––– */
.page-header {
background: var(--main-white-color);
}
.page-header nav {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-items: center;
}
.page-header ul {
display: flex;
order: 1;
width: 100%;
margin-top: 15px;
}
.page-header ul li:not(:last-child) {
padding-right: 15px;
}
.page-header .cta-contact {
font-family: inherit;
font-size: 1.2rem;
padding: 5px 18px;
border: 1px solid;
border-radius: 5px;
}
/* MAIN
–––––––––––––––––––––––––––––––––––––––––––––––––– */
.page-main {
display: flex;
flex-direction: column;
justify-content: center;
flex-grow: 1;
min-height: 350px;
background: var(--main-purple-color)
url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/162656/city.jpg) no-repeat
center / cover;
background-blend-mode: luminosity;
color: var(--main-white-color);
}
.page-main div {
max-width: 500px;
}
.page-main h1 {
margin-bottom: 20px;
}
.page-main p + p {
margin-top: 10px;
}
/* FOOTER
–––––––––––––––––––––––––––––––––––––––––––––––––– */
.page-footer {
display: flex;
flex-direction: column-reverse;
background: var(--main-white-color);
}
.page-footer ul {
display: flex;
font-size: 1.5rem;
margin-bottom: 5px;
}
.page-footer ul li:not(:last-child) {
margin-right: 20px;
}
/* MQ
–––––––––––––––––––––––––––––––––––––––––––––––––– */
@media screen and (min-width: 550px) {
.page-header ul {
width: auto;
margin-top: 0;
}
.page-header .cta-contact {
order: 1;
}
.page-footer {
flex-direction: row;
justify-content: space-between;
align-items: center;
}
.page-footer ul {
margin-bottom: 0;
}
}
@media screen and (min-width: 768px) {
body {
font-size: 18px;
}
.page-main {
padding-left: 90px;
}
}
/* ANIMATIONS
–––––––––––––––––––––––––––––––––––––––––––––––––– */
.page-header nav > *,
.page-main,
.page-footer > * {
opacity: 0;
}
.page-header,
.page-footer,
.page-main .text-wrapper {
overflow: hidden;
}
.page-header nav > * {
transform: translateY(-30px);
}
.page-footer > * {
transform: translateY(30px);
}
.page-header {
position: relative;
}
.page-header::after {
content: "";
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 2px;
background: var(--main-purple-color);
z-index: 99999;
transform: scaleX(0);
}
.page-main .text-wrapper + .text-wrapper {
margin-top: 10px;
}
.page-main .text-wrapper * {
transform: translateY(120%);
}
.page-main .p-wrapper * {
transform: translateY(-120%);
}
.loaded .page-header::after {
animation: scaleIn 1.3s ease-in 0.2s forwards;
}
.loaded .page-main {
animation: fadeIn 1s ease-in 0.7s forwards;
}
.loaded .page-header nav > *,
.loaded .page-footer > * {
animation: fadeIn 1s ease-in 0.7s forwards, slideIn 0.8s ease-in 0.9s forwards;
}
.loaded .page-main .text-wrapper * {
animation: slideIn 0.6s cubic-bezier(0.54, 0.46, 0.54, 0.94) 2s forwards;
}
@keyframes fadeIn {
60% {
opacity: 0;
}
100% {
opacity: 1;
}
}
@keyframes scaleIn {
100% {
transform: scaleX(1);
}
}
@keyframes slideIn {
100% {
transform: translateY(0);
}
}
<link href="https://unpkg.com/ionicons@4.4.6/dist/css/ionicons.min.css" rel="stylesheet" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment