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.
<!-- fun CSS image and animation effects! -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Quicksand:wght@300&display=swap" rel="stylesheet" />
<link rel="stylesheet" href="mystyles.css" />
<title>Parallax</title>
<script src="https://kit.fontawesome.com/41c8573884.js" crossorigin="anonymous"></script>
</head>
<body>
<!-- back to top button -->
<button onclick="topFunction()" id="top-button" title="Go to top">
<i class="fas fa-long-arrow-alt-up"></i></i>
</button>
<!-- PARALLAX -->
<!-- first parallax section -->
<section class="first">
<!-- HEADING -->
<section class="parallax-img-1">
<div class="section-heading">
<br />
<h1>birth</h1>
<br />
</div>
</section>
<!-- lorem ipsum -->
<h2>
Aliqua amet esse elit eiusmod irure Lorem incididunt exercitation
magna ullamco. Cillum occaecat eiusmod culpa duis nisi do laborum.
Nulla et reprehenderit veniam duis dolor ullamco consectetur non
exercitation exercitation officia in. Et id velit non id eiusmod sit
dolor do non ex. Ipsum enim duis labore ut excepteur est esse
incididunt.
</h2>
<h2>
Velit id est tempor labore est ullamco duis non id enim nulla
tempor. Nisi incididunt proident labore culpa velit aliquip eiusmod.
Magna enim qui deserunt ipsum irure. Est esse deserunt esse velit
nisi quis consequat et est.
</h2>
<h2>
Irure aute dolore proident eiusmod sint minim adipisicing laborum
excepteur. Quis aliqua magna culpa ut esse amet sint sunt. Non
adipisicing aliquip elit officia nostrud deserunt est. Mollit
nostrud amet officia aute nostrud dolor enim et. Ullamco eu sit
veniam reprehenderit pariatur et cupidatat. Proident irure
reprehenderit proident excepteur sunt cillum sit proident veniam.
</h2>
<!-- second parallax section -->
<!-- HEADING -->
<section class="parallax-img-2">
<div class="section-heading">
<br />
<h1>life</h1>
<br />
</div>
</section>
</section>
<section class="second">
<!-- lorem ipsum -->
<h2>
Nostrud velit excepteur ipsum non proident incididunt sunt anim
tempor ex laborum ea aute ut. Incididunt ex mollit irure sunt do
minim aliquip occaecat quis. Ex dolore officia deserunt ipsum velit
quis dolore. Id laboris ea adipisicing culpa aliqua Lorem non
nostrud. Cillum ex amet aute dolore do ad do laboris pariatur enim
sint sint velit in. Do pariatur consequat irure fugiat pariatur.
Commodo id ea minim et consectetur et pariatur.
</h2>
<h2>
Veniam nulla velit veniam nisi amet ullamco. Sunt aliquip nostrud
Lorem aute. Velit ex est laboris reprehenderit. Exercitation amet
deserunt eiusmod anim dolor ea sunt nulla mollit do ex aliquip in
deserunt. Elit eiusmod do Lorem reprehenderit nulla cupidatat
consequat velit ullamco aliquip cupidatat. Ipsum ex quis dolor ut
fugiat ullamco id ad ullamco mollit dolor veniam. Voluptate minim do
eu tempor pariatur.
</h2>
<h2>
Ut cillum cupidatat pariatur laboris id. Anim adipisicing amet
aliquip enim. Eiusmod mollit sint quis laboris enim incididunt culpa
nulla exercitation nisi culpa.
</h2>
<!-- third parallax section -->
<!-- HEADING -->
<section class="parallax-img-3">
<div class="section-heading">
<br />
<h1>death</h1>
<br />
</div>
</section>
<!-- lorem ipsum -->
<h2>
Non consectetur exercitation laboris mollit esse. Minim tempor duis
eiusmod dolore aliquip aute sit deserunt reprehenderit duis aute.
Excepteur elit cillum mollit adipisicing pariatur et mollit
excepteur non.
</h2>
<h2>
Aliqua pariatur voluptate non sunt elit fugiat sunt culpa dolore.
Consequat ex aliqua Lorem nostrud. Magna officia ut sint ad eiusmod
mollit. Pariatur tempor aliqua labore eu culpa amet aliquip qui
tempor nulla adipisicing. Aliqua laborum elit cupidatat consectetur
eiusmod incididunt exercitation amet exercitation officia magna ad
mollit. Dolor reprehenderit amet incididunt qui officia occaecat
amet. Enim non ipsum pariatur amet non non velit duis esse est.
</h2>
<h2>
Irure deserunt exercitation tempor excepteur. Sit eu ea do ex amet
laborum enim nostrud cupidatat. In minim aute est amet velit
commodo.
</h2>
</section>
<!-- FOOTER -->
<footer>
<p>Developed by Raya Bergin © v2-4Feb2022</p>
<div class="footer-flex">
<p>Credits:</p>
<p>1st photo by Isaac Quesada on Unsplash</p>
<p>2nd photo by Mohamed Nohassi on Unsplash</p>
<p>3rd photo by Kenny Orr on Unsplash</p>
</div>
</footer>
<script src="myscripts.js"></script>
</body>
</html>
/* MY TEMPLATE RESET */
* {
/* Outline to view layout on screen while styling | Remove after styling */
/* outline: 1px dashed #ff0075; */
margin: 0;
padding: 0;
scroll-behavior: smooth;
}
html {
box-sizing: border-box;
font-size: 100%;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
/* color variables */
:root {
--beige: #fef5ed;
--dark-purple: #150050;
--baby-blue: #e0ffff;
--grayish-light-green: #acd1af;
--light-purple: #af8fe9;
}
/* body styles */
body {
font-family: "Quicksand", sans-serif;
background-color: var(--beige);
width: 100%;
max-width: 100em;
margin: 0 auto;
}
/* back to the top button */
#top-button {
display: none;
position: fixed;
bottom: 1.5em;
right: 1.5em;
z-index: 2;
font-size: 2rem;
border: none;
outline: none;
background-color: var(--dark-purple);
color: var(--baby-blue);
cursor: pointer;
padding: 0.5em;
border-radius: 0.25em;
}
#top-button:hover {
color: var(--dark-purple);
background-color: var(--baby-blue);
}
/* PARALLAX */
/* first parallax section */
.parallax-img-1 {
background: url(https://images.unsplash.com/photo-1591161555818-7b9debeccc07?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=2070&q=80)
no-repeat fixed 100%;
background-size: cover;
color: var(--baby-blue);
}
/* second parallax section */
.parallax-img-2 {
background: url(https://images.unsplash.com/photo-1490730141103-6cac27aaab94?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=2070&q=80)
no-repeat fixed 100%;
background-size: cover;
color: var(--grayish-light-green);
}
/* third parallax section */
.parallax-img-3 {
background: url(https://images.unsplash.com/photo-1581588525251-e1dca48e9827?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=2070&q=80)
no-repeat fixed 100%;
background-size: cover;
color: var(--light-purple);
}
/* PARALLAX headings */
.section-heading {
padding-top: 25%;
padding-bottom: 25%;
}
h1 {
font-size: 10em;
text-align: center;
}
h2 {
color: var(--dark-purple);
margin: 2em 3.25em 2em 3.25em;
line-height: 1.5;
}
/* FOOTER */
footer {
margin: 1em 1em;
padding: 1em 0;
}
.footer-flex {
display: flex;
justify-content: center;
flex-direction: column;
line-height: 1.5;
}
/* laptop styles */
/* max-width 64em (1024px) */
@media (max-width: 64em) {
/* back to the top button */
#top-button {
bottom: 1em;
right: 1em;
}
/* PARALLAX headings */
h2 {
margin: 2em;
}
}
/* tablet styles */
/* max-width 48em (768px) */
@media (max-width: 48em) {
/* back to the top button */
#top-button {
bottom: 0.75em;
right: 0.75em;
}
/* PARALLAX headings */
h2 {
margin: 1.5em;
}
}
/* mobile styles */
/* max-width 26.5625em (425px) */
/* turn off parallax scrolling for mobile */
@media (max-width: 26.5625em) {
/* back to the top button */
#top-button {
bottom: 0.5em;
right: 0.5em;
}
/* PARALLAX */
/* first parallax section */
.parallax-img-1,
/* second parallax section */
.parallax-img-2,
/* third parallax section */
.parallax-img-3 {
background-attachment: scroll;
}
/* PARALLAX headings */
h1 {
font-size: 6em;
}
h2 {
margin: 1em;
}
}
//Get the button
var mybutton = document.getElementById("top-button");
// When the user scrolls down 300px from the top of the document, show the button
window.onscroll = function () {
scrollFunction();
};
function scrollFunction() {
if (
document.body.scrollTop > 300 ||
document.documentElement.scrollTop > 300
) {
mybutton.style.display = "block";
} else {
mybutton.style.display = "none";
}
}
// When the user clicks on the button, scroll to the top of the document
function topFunction() {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
}
Also see: Tab Triggers