JSFiddle - React, Tailwind, and code Playground
by Hamzailyas434
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<link rel="shortcut icon" type="image/png" href="img/icon.png" />
<link
href="https://fonts.googleapis.com/css?family=Poppins:300,400,500,600&display=swap"
rel="stylesheet"
/>
<link rel="stylesheet" href="style.css" />
<title>Bankist | When Banking meets Minimalist</title>
</head>
<body>
<header class="header">
<nav class="nav">
<img
...
CSS
:root {
--color-primary: #5ec576;
--color-secondary: #ffcb03;
--color-tertiary: #ff585f;
--color-primary-darker: #4bbb7d;
--color-secondary-darker: #ffbb00;
--color-tertiary-darker: #fd424b;
--color-primary-opacity: #5ec5763a;
--color-secondary-opacity: #ffcd0331;
--color-tertiary-opacity: #ff58602d;
--gradient-primary: linear-gradient(to top left, #39b385, #9be15d);
--gradient-secondary: linear-gradient(to top left, #ffb003, #ffcb03);
}
* {
margin: 0;
padding: 0;
box-sizing: inherit;
}
html {
font-size: 62.5%;
box-sizing: border-box;
}
body {
font-family: 'Poppins', sans-serif;
font-weight: 300;
color: #444;
line-height: 1.9;
background-color: #f3f3f3;
}
/* GENERAL ELEMENTS */
.section {
padding: 15rem 3rem;
border-top: 1px solid #ddd;
transition: transform 1s, opacity 1s;
}
.section--hidden {
opacity: 0;
transform: translateY(8rem);
}
.section__title {
max-width: 80rem;
margin: 0 auto 8rem auto;
}
.section__description {
font-size: 1.8rem;
font-weight: 600;
text-transform: uppercase;
color: var(--color-primary);
margin-bottom: 1rem;
}
.section__header {
font-size: 4rem;
line-height: 1.3;
font-weight: 500;
}
.btn {
display: inline-block;
background-color: var(--color-primary);
font-size: 1.6rem;
font-family: inherit;
font-weight: 500;
border: none;
padding: 1.25rem 4.5rem;
border-radius: 10rem;
cursor: pointer;
transition: all 0.3s;
}
.btn:hover {
background-color: var(--color-primary-darker);
}
.btn--text {
display: inline-block;
background: none;
font-size: 1.7rem;
font-family: inherit;
font-weight: 500;
color: var(--color-primary);
border: none;
border-bottom: 1px solid currentColor;
padding-bottom: 2px;
cursor: pointer;
transition: all 0.3s;
}
p {
color: #666;
}
/* This is BAD for accessibility! Don't do in the real world! */
button:focus {
outline: none;
}
img {
transition: filter 0.5s;
}
.lazy-img {
filter:...
JavaScript
/* Smooth Scroll Navigation */
document.querySelector('.nav__links').addEventListener('click', function (e) {
console.log(e.target);
// Matching stratgey
e.preventDefault();
if (e.target.classList.contains('nav__link')) {
const id = e.target.getAttribute('href');
document.querySelector(id).scrollIntoView({ behavior: 'smooth' });
}
});
/* Sticky Navigation */
const nav = document.querySelector('.nav');
const header = document.querySelector('.header');
const navHeight = nav.getBoundingClientRect().height;
const stickyNav = function (entries) {
const [entry] = entries;
if (!entry.isIntersecting) nav.classList.add('sticky');
else nav.classList.remove('sticky');
};
let options = {
root: null,
threshold: 0,
rootMargin: `-${navHeight}px`,
};
const headerObserver = new IntersectionObserver(stickyNav, options);
headerObserver.observe(header);