HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URL's added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<!-- reverse engineered this website: https://www.oneplus.com/uk/6 -->
<!--
if i had more time i would make:
1) the menu collapse into three bars that:
a) animates when clicked on
b) expands into a sidebar style menu
2) make the footer more detailed (using CSS3 grid)
-->
<header id="header">
<img src="https://res.cloudinary.com/ahmedagadir/image/upload/v1530726627/product-landing-page/logo.jpg" alt="OnePlus logo" id="header-img">
<h1>OnePlus 6</h1>
<div class="user-details">
<span><i class="fa fa-user"></i></span>
<span><i class="fa fa-shopping-bag"></i></span>
<span>🇬🇧</span>
</div>
<nav id="nav-bar">
<ul>
<li><a class="nav-link" href="#speed">speed</a></li>
<li><a class="nav-link" href="#display">display</a></li>
<li><a class="nav-link" href="#camera">camera</a></li>
<li><a class="nav-link" href="#design">design</a></li>
<li><a class="nav-link" href="#oxygenos">OxygenOS</a></li>
<li><a class="nav-link" href="#resistance">resistance</a></li>
<li><a class="nav-link" href="#headphones">headphones</a></li>
</ul>
<button><span></span>Buy now</button>
</nav>
</header>
<main>
<div class="block one">
<p class="d2">OnePlus 6</p>
<p class="d2">Lorem ipsum dolor</p>
<p class="d3">From £469</p>
</div>
<div id="block1">
<img src="https://res.cloudinary.com/ahmedagadir/image/upload/v1530726593/product-landing-page/block1.jpg" alt="phone1">
</div>
<div class="block two">
<button>
<i class="fa fa-play"></i>
<img src="https://res.cloudinary.com/ahmedagadir/image/upload/v1530726627/product-landing-page/block2a.jpg" alt="phone">
</button>
<button>
<i class="fa fa-play"></i>
<img src="https://res.cloudinary.com/ahmedagadir/image/upload/v1530726630/product-landing-page/block2b.jpg" alt="phone">
</button>
</div>
<div class="block three" id="speed">
<p class="d1">Fast and Smooth</p>
<p class="d2">The Speed You Need.</p>
<p class="d3">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse.</p>
<p class="d4"><a href=#>Learn more</a></p>
</div>
<div id="block3">
<img src="https://res.cloudinary.com/ahmedagadir/image/upload/v1530726614/product-landing-page/block3.png" alt="phone3">
</div>
<div class="block four" id="display">
<p class="d1">Display</p>
<p class="d2">More to see.</p>
<p class="d3">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor.</p>
<p class="d4"><a href=#>Learn more</a></p>
</div>
<div id='block4'>
<img src="https://res.cloudinary.com/ahmedagadir/image/upload/v1530726612/product-landing-page/block4.png" alt="phone4">
</div>
<div class="block five" id="camera">
<p class="d1">Dual Camera</p>
<p class="d2">Capture in no time.</p>
<p class="d3">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo.</p>
<p class="d4"><a href=#>Learn more</a></p>
</div>
<div id='block5'>
<img src="https://res.cloudinary.com/ahmedagadir/image/upload/v1530726621/product-landing-page/block5.png" alt="phone5">
</div>
<div class="block six" id="design">
<p class="d1">Design</p>
<p class="d2">The OnePlus way.</p>
<p class="d3">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam.</p>
<p class="d4"><a href=#>Learn more</a></p>
</div>
<div id='block6'>
<img src="https://res.cloudinary.com/ahmedagadir/image/upload/v1530726605/product-landing-page/block6.jpg" alt="phone6">
</div>
<div class="block seven" id="oxygenos">
<p class="d1">OxyenOS</p>
<p class="d2">Do more with less.</p>
<p class="d3">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et.</p>
<p class="d4"><a href=#>Learn more</a></p>
</div>
<div id='block7'>
<img src="https://res.cloudinary.com/ahmedagadir/image/upload/v1530726621/product-landing-page/block7a.png" alt="phone7a">
<img src="https://res.cloudinary.com/ahmedagadir/image/upload/v1530726623/product-landing-page/block7b.png" alt="phone7b">
<img src="https://res.cloudinary.com/ahmedagadir/image/upload/v1530726628/product-landing-page/block7c.png" alt="phone7c">
</div>
<div class="block eight" id="resistance">
<p class="d1">Water Resistant</p>
<p class="d2">Guard against rain.</p>
<p class="d3">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex.</p>
<p class="d4"><a href=#>Learn more</a></p>
</div>
<div id='block8'>
<img src="https://res.cloudinary.com/ahmedagadir/image/upload/v1530726620/product-landing-page/block8.jpg" alt="phone8">
</div>
<div class="block nine" id="headphones">
<p class="d1">Bullet Wireless</p>
<p class="d2">Best Buds for Life.</p>
<p class="d3">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim ven.</p>
<p class="d4"><a href=#>Learn more</a></p>
</div>
<div id='block9'>
<img src="https://res.cloudinary.com/ahmedagadir/image/upload/v1530726631/product-landing-page/block9.jpg" alt="phone9">
</div>
<div id="modal">
<span>×</span>
<div class="video-wrapper">
<iframe id="video" width="560" height="315" src="https://www.youtube.com/embed/GcXUi1Xj9i8?rel=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
</div>
<div class="video-wrapper">
<iframe id="video" width="560" height="315" src="https://www.youtube.com/embed/IQSYW2aiVvk?rel=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
</div>
</div>
</main>
<footer>
<div class="contact">
<form action="https://www.freecodecamp.com/email-submit" method="POST" id="form">
<p>join our newsletter</p>
<input type="email" name="user_mail" placeholder="e.g. johnsmith@mail.com" id="email"required>
<button type="submit" id="submit"><span></span>suscribe</button>
</form>
<div class="social-media">
<p>keep updated</p>
<a><i class="fab fa-facebook"></i></a>
<a><i class="fab fa-instagram"></i></a>
<a><i class="fab fa-twitter"></i></a>
</div>
</div>
<div class="bottom">
<p><span>🇬🇧</span> United Kingdom (English / GBP)</p>
<p><span class="phone-number"><i class="fa fa-phone"></i> +55 5555 5555555</span>, 9:30am - 3:00am, Monday to Sunday</p>
<hr>
<span>© 2013 - 2018 OnePlus. All Rights Reserved</span>
<a href="#" target="_blank">Privacy Policy</a>
<a href="#" target="_blank">User Agreement</a>
<a href="#" target="_blank">Terms of Sales</a>
</div>
</footer>
<a href="https://github.com/AhmedAGadir" target="_blank"><img src="https://res.cloudinary.com/ahmedagadir/image/upload/v1530726623/product-landing-page/github-sign.svg" alt="link to my github" title="Check out my github"></a>
@import url('https://fonts.googleapis.com/css?family=Comfortaa|Open+Sans:300,400,600,700');
* {
padding: 0;
margin: 0;
box-sizing: border-box;
font-family: 'Open Sans', sans-serif;
}
a {
text-decoration: none;
color: inherit;
}
/* ========== header and navbar styling =========*/
header {
width: 100%;
padding: 10px 40px;
border-bottom: 1px solid #E5E5E5;
background-color: white;
position: fixed;
top: 0;
transition: all 0.25s ease;
z-index: 3;
display: flex;
justify-content: space-between;
align-items: flex-end;
flex-wrap: wrap;
}
header img {
height: 30px;
}
@media (max-width: 330px) {
header img {
display: none;
}
}
header h1 {
font-size: 1.1rem;
font-weight: 600;
color: #101920;
margin-left: 185px;
}
@media (max-width: 600px) {
h1 {
display: none;
}
}
header .user-details span {
margin-left: 20px;
font-size: 1.2rem;
color: #828282;
padding: 0 15px 10px 15px;
}
header .user-details span:hover {
color: #101920;
border-bottom: 2px solid #101920;
cursor: pointer;
}
nav {
padding: 15px 15px 0 15px;
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
}
nav ul {
display: flex;
flex-wrap: wrap;
justify-content: center;
margin: 0 auto;
}
@media (max-width: 600px) {
nav ul {
margin: unset;
display: unset;
position: relative;
right: 30px;
}
}
nav li {
list-style-type: none;
}
nav li a {
margin: 0 15px;
padding: 10px 5px 15px 5px;
color: #828282;
text-transform: uppercase;
letter-spacing: 0.05rem;
font-size: 0.8rem;
}
nav li a:hover {
color: #EB0028;
border-bottom: 2px solid #EB0028;
}
nav button {
/*remove default styling*/
/*outline: none;*/
border: none;
box-shadow: none;
min-width: 110px;
height: 50px;
background: #EB0028;
color: white;
font-size: 0.9rem;
border-radius: 2px;
position: relative;
z-index: 1;
}
nav button span {
position: absolute;
top: 0;
left: 0;
border-radius: 2px;
background: #CE0024;
height: 100%;
z-index: -1;
/*javascript used for animation-name setting*/
animation-duration: 0.5s;
animation-fill-mode: forwards;
}
nav button:hover {
cursor: pointer;
}
@keyframes buttonEffect {
0% {
width: 0px;
}
100% {
width: 100%;
}
}
@keyframes buttonEffectRemoval {
0% {
width: 100%;
}
100% {
width: 0px;
}
}
@media (max-width: 1000px) {
nav li a {
padding-bottom: 0px;
}
}
/* ========== main body styling =========*/
main {
text-align: center;
}
.block {
padding: 50px;
/*padding top needed for navbar links */
padding-top: 50px;
}
@media (max-width: 780px) {
.block:not(.one):not(.two) {
text-align: left;
}
.d4 {
text-align: center;
}
}
.d1:nth-of-type(odd), .d2:nth-of-type(odd) {
background: linear-gradient(to right, #cda330, #73622a);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.d1:nth-of-type(even), .d2:nth-of-type(even) {
background: linear-gradient(to right, #762FC4 ,black 90%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.d1 {
font-family: 'Comfortaa', cursive;
font-size: 1.5rem;
font-weight: 700;
margin-top: 30px;
}
.d2 {
font-family: 'Comfortaa', cursive;
font-size: 3.5rem;
font-weight: 700;
padding: 13px 0;
}
.d3 {
font-size: 1.2rem;
color: #676767;
}
.d4 {
margin: 40px auto;
width: 135px;
font-size: 1.3rem;
padding: 0 10px;
border-bottom: 2px solid #101920;
transition: 0.2s all ease-in;
position: relative;
z-index: 2;
}
.d4:hover {
width: 150px;
color: #EB0028;
padding: 0 10px;
border-bottom: 2px solid #EB0028;
}
.one .d2:first-child {
margin-top: 200px;
padding-bottom: 0;
font-size: 3.5rem;
font-weight: 400;
-webkit-text-fill-color: black;
}
.one .d2:nth-child(2) {
font-size: 4rem;
font-weight: 600;
-webkit-text-fill-color: black;
}
.one .d3 {
font-size: 2.5rem;
font-weight: 400;
margin-bottom: 20vh;
}
/* ========== images ========= */
main > img {
display: block;
margin: 60px auto;
}
img[alt="phone1"] {
width: 40%;
}
/* */
.two {
position: relative;
top: -20vh;
padding: 0;
display: flex;
height: 65vh;
transform-origin: left;
transform: skewY(-3.5deg);
overflow: hidden;
}
.two .fa-play {
font-size: 2rem;
color: white;
margin-top: 30vh;
transition: all 0.5s ease
}
.two .fa-play:hover {
/*set using javascript*/
}
.two > button > img {
width: 50vw;
visibility: hidden;
}
.two button {
/*remove default styling*/
/*outline: none;*/
border: none;
box-shadow: none;
transform: skewY(3.5deg);
transform-origin: right;
height: 100vh;
transition: all 0.5s ease;
}
.two > button:first-child {
background: url('https://res.cloudinary.com/ahmedagadir/image/upload/v1530726627/product-landing-page/block2a.jpg');
background-size: 50vw;
background-position: left 5vh;
background-attachment: fixed;
background-repeat: no-repeat;
}
.two > button:last-child {
background: url('https://res.cloudinary.com/ahmedagadir/image/upload/v1530726630/product-landing-page/block2b.jpg');
background-size: 50vw;
background-position: right 5vh;
background-attachment: fixed;
background-repeat: no-repeat;
}
.two button:hover {
background-blend-mode: hard-light;
cursor: pointer;
}
.two button:first-child:hover {
background-color: #8974C2;
}
.two button:last-child:hover {
background-color: #C6B27B;
}
@media (max-width: 900px) {
.two > button:first-child,
.two > button:last-child {
background-size: 80vw;
}
}
@media (max-width: 500px) {
.two > button:first-child,
.two > button:last-child {
background-size: 130vw;
}
}
/* ========== modal styling =========*/
#modal {
position: fixed;
background-color: rgba(0,0,0,1);
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 4;
transition: all 0.5s ease;
opacity: 0;
display: none;
}
#modal span {
font-size: 40px;
color: white;
float: right;
padding: 10px 20px 0 20px;
display: none;
transition: all 0.3s ease;
cursor: pointer;
}
#modal span:hover {
color: #EB0028;
}
#modal .video-wrapper {
clear: right;
position: relative;
padding-bottom: 56.25%; /* 16:9 aspect ratio; */
height: 0;
display: none;
}
#modal iframe {
position: absolute;
top: 0;
left: 0;
width: 70%;
height: 70%;
margin-left: 15vw;
}
/* ========== more images =========*/
img[alt="phone3"] {
width: 80%;
}
#block4 img[alt="phone4"],
#block5 img[alt="phone5"],
#block6 img[alt="phone6"],
#block8 img[alt="phone8"],
#block9 img[alt="phone9"] {
width: 50%;
visibility: hidden;
height: 120vh;
}
#block4 {
background: url('https://res.cloudinary.com/ahmedagadir/image/upload/v1530726612/product-landing-page/block4.png');
background-size: 80vh;
background-attachment: scroll;
background-position: center 25vh;
z-index: 1;
}
#block5 {
background: url('https://res.cloudinary.com/ahmedagadir/image/upload/v1530726621/product-landing-page/block5.png');
background-size: 80vh;
background-attachment: scroll;
background-position: center 25vh;
z-index: 1;
}
#block6 {
background: url('https://res.cloudinary.com/ahmedagadir/image/upload/v1530726605/product-landing-page/block6.jpg');
background-size: 100vw;
background-attachment: fixed;
background-position-y: -10vh;
}
#block8 {
background: url('https://res.cloudinary.com/ahmedagadir/image/upload/v1530726620/product-landing-page/block8.jpg');
background-size: 120vw;
background-attachment: fixed;
background-position: center;
}
#block9 {
background: url('https://res.cloudinary.com/ahmedagadir/image/upload/v1530726631/product-landing-page/block9.jpg');
background-size: 100vw;
background-attachment: scroll;
background-position: center;
margin-bottom: 20vh;
}
#block4,
#block5,
#block6,
#block8,
#block9 {
background-color: #674CAF;
background-repeat: no-repeat;
position: relative;
}
@media (max-width: 768px) {
#block9 {
background-size: 200vw;
}
}
@media (max-width: 425px) {
#block4, #block5 {
background-size: 50vw;
}
#block6 {
background-size: 170vw;
}
#block8 {
background-size: 230vw;
}
}
@media (max-width: 375px) {
#block9 img[src="https://res.cloudinary.com/ahmedagadir/image/upload/v1530726631/product-landing-page/block9.jpg"] {
height: 100vh
}
}
/* ========== skewed borders effect =========*/
#block4:before, #block4:after,
#block5:before, #block5:after,
#block6:before, #block6:after,
#block8:before, #block8:after,
#block9:before {
position: absolute;
left: 0;
content: '';
width: 100%;
height: 20vh;
background: white;
transform: skewY(-3.5deg);
}
#block4:before,
#block5:before,
#block6:before,
#block8:before,
#block9:before {
top: 0;
transform-origin: bottom left;
}
#block4:after,
#block5:after,
#block6:after,
#block8:after {
bottom: 0;
transform-origin: top right;
}
#block7 {
margin: 15vh auto;
width: 80%;
display: flex;
align-items: flex-start;
justify-content: space-around;
flex-direction: wrap;
}
#block7 img {
position: relative;
max-width: 30%;
}
#block7 img:nth-of-type(1) {
margin-top: 260px;
}
#block7 img:nth-of-type(2) {
margin-top: 160px;
}
#block7 img:nth-of-type(3) {
margin-top: 60px;
}
/* ========== fading in animtions =========*/
/*animation names are set using JS */
.block:not(.two) {
position: relative;
top: -45px;
z-index: 2;
animation-duration: 0.9s;
animation-fill-mode: forwards;
animation-timing-function: ease-out;
visibility: hidden;
}
#block7 img {
animation-fill-mode: forwards;
animation-timing-function: ease-out;
visibility: hidden;
}
#block7 img:nth-child(1) {
animation-delay: 200ms;
animation-duration: 800ms;
}
#block7 img:nth-child(2) {
animation-delay: 100ms;
animation-duration: 900ms;
}
#block7 img:nth-child(3) {
animation-delay: 0;
animation-duration: 1000ms;
}
@keyframes fade-in-a {
0% {
top: 35px;
opacity: 0.1;
}
100% {
visibility: unset;
top: 0px;
opacity: 1;
}
}
#block4, #block5 {
animation-duration: 1s;
animation-delay: 100ms;
animation-fill-mode: forwards;
animation-timing-function: ease-out;
visibility: hidden;
}
@keyframes fade-in-b {
0% {
background-position: center 35vh;
opacity: 0.1;
}
100% {
visibility: unset;
background-position: center 25vh;
opacity: 1;
}
}
/* ========== footer =========*/
footer {
border-top: 2px solid #E5E5E5;
display: flex;
flex-wrap: wrap;
color: #828282;
justify-content: space-between;
margin: 5vh 0;
}
.contact, .bottom {
width: 100%;
padding: 40px 20px 0 20px;
}
.contact {
display: flex;
flex-wrap: wrap;
text-align: center;
}
.contact p,
.contact button {
font-size: 1.2rem;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.05rem;
}
.contact p {
margin-bottom: 20px;
}
.contact form,
.contact .social-media {
flex: 1 400px;
margin-bottom: 40px;
}
.contact input[type="email"] {
width: 250px;
height: 40px;
font-size: 1rem;
text-indent: 5px;
box-shadow: none;
-webkit-appearance: none;
-moz-appearance: none;
-o-appearance: none;
-ms-appearance: none;
appearance: none;
}
.contact button {
width: 110px;
height: 40px;
font-size: 0.9rem;
background-color: #00C4ED;
color: white;
transition: all 0.3s ease;
border: 0;
outline: none;
box-shadow: none;
border-radius: 2px;
position: relative;
z-index: 1;
}
.contact button span {
position: absolute;
top: 0;
left: 0;
border-radius: 2px;
background: #00A7CA;
height: 100%;
z-index: -1;
/*animation-name: buttonEffect or buttonEffectRemoval // set using javascript;*/
animation-duration: 0.5s;
animation-fill-mode: forwards;
}
.contact button:hover {
/*background-color: #00A7CA;*/
cursor: pointer;
}
@media (max-width: 425px) {
.contact button {
margin-top: 10px;
}
}
.contact .social-media i {
font-size: 2rem;
padding: 0px 20px;
color: #828282;
transition: all 0.3s ease;
}
.contact .social-media i:hover {
color: #EB0028;
cursor: pointer;
}
.bottom {
background-color: #F9F9F9;
}
.bottom .phone-number {
color: #49B5D9
}
.bottom p {
padding: 10px 0;
}
.bottom p:first-of-type {
float: left;
}
.bottom p:last-of-type {
float: right;
}
.bottom hr {
clear: both;
margin: 20px 0;
border-top: 1px solid #E5E5E5;
}
@media (max-width: 768px) {
.bottom p:first-of-type,
.bottom p:last-of-type {
float: initial;
}
}
.bottom > span,
.bottom > a {
font-size: 0.8rem;
margin-right: 20px;
}
/* ========== github logo =========*/
img[alt="link to my github"] {
position: fixed;
bottom: 0;
right: 0;
width: 40px;
margin: 20px;
opacity: 0.7;
transition: all 0.3s ease;
}
img[alt="link to my github"]:hover {
opacity: 1;
}
/*
dark: 101920;
#676767
middle: 828282;
light: E5E5E5;
middle-grey: #828282;
light: #B6B6B6;
superlight: ##E5E5E5;
red: #EB0028;
lilac: #BE9AE1;
purple: #4F499A;
dark-purple: #1F2566;
light-blue: #00ABDC;
*/
// ============= SCROLLING ANIMATIONS =================
window.addEventListener('DOMContentLoaded', e => {
document.querySelector('.one').style.animationName = 'fade-in-a';
})
window.addEventListener('scroll', e => {
// console.log(parseInt(document.querySelector('.three').getBoundingClientRect()['top']), parseInt(innerHeight) + 200)
if (pageYOffset > 30) {
document.querySelector('header').style.top = (innerWidth < 600) ? '-50px' : '-45px';
} else {
document.querySelector('header').style.top = '0px';
}
// hecks whether the element is within the limits of the viewport or not
let fade = (element, animationName) => {
if (element.getBoundingClientRect()['top'] < innerHeight)
element.style.animationName = animationName;
};
Array.from(document.querySelectorAll('.block:not(.one):not(.two)')).forEach(block => fade(block, 'fade-in-a'));
Array.from(document.querySelectorAll('#block7 img')).forEach(image => fade(image, 'fade-in-a'));
fade(document.querySelector('#block4'), 'fade-in-b');
fade(document.querySelector('#block5'), 'fade-in-b');
})
// ============= VIDEO AND MODAL STYLING =================
Array.from(document.querySelectorAll('.two button')).forEach((button, ind) => {
button.addEventListener('mouseover', () => button.firstElementChild.style.color = '#EB0028')
button.addEventListener('mouseout', () => button.firstElementChild.style.color = '#FFF')
button.addEventListener('click', () => openModal(ind))
})
function openModal(ind) {
document.querySelectorAll('.video-wrapper iframe')[ind].src += '&autoplay=1';
document.querySelector('#modal').style.display = 'block';
document.querySelector('#modal span').style.display = 'block';
document.getElementsByClassName('video-wrapper')[ind].style.display = 'block';
setTimeout( () => document.querySelector('#modal').style.opacity = '1', 100)
}
document.querySelector('#modal span').addEventListener('click', closeModal);
document.querySelector('#modal').addEventListener('click', closeModal);
function closeModal() {
document.querySelector('#modal').style.opacity = '0';
setTimeout( () => {
document.querySelector('#modal').style.display = 'none';
document.querySelector('#modal span').style.display = 'none';
Array.from(document.getElementsByClassName('video-wrapper')).forEach(wrapper => wrapper.style.display = 'none');
}, 500)
Array.from(document.querySelectorAll('.video-wrapper iframe')).forEach(iframe => {
// replace the source attribute with itself to reset the video
// also remove the autoplay
iframe.src = iframe.src.replace('&autoplay=1','');;
})
}
// ============= NAVIGATION BAR AND CONTACT BUTTON EFFECT =================
document.querySelector('nav button').addEventListener('mouseover', () => {
document.querySelector('nav button span').style.animationName = 'buttonEffect'
})
document.querySelector('nav button').addEventListener('mouseout', () => {
document.querySelector('nav button span').style.animationName = 'buttonEffectRemoval'
})
document.querySelector('.contact button').addEventListener('mouseover', () => {
document.querySelector('.contact button span').style.animationName = 'buttonEffect'
})
document.querySelector('.contact button').addEventListener('mouseout', () => {
document.querySelector('.contact button span').style.animationName = 'buttonEffectRemoval'
})
Also see: Tab Triggers