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 URLs 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 its URL and the proper URL extension.
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 esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM 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.
<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=Montserrat:wght@400;800&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;800&display=swap" rel="stylesheet">
<div class="rpb-main">
<div class="rp-bar">
<div class="rp-bar-inner">
</div>
</div>
<div class="rpb-header">
<h1>How to Add a Reading Progress Bar on your Shopify Blogs
</h1>
<a class="rdc-credits" href="https://www.reddelacruz.dev/tutorials" target="blank">by rdc</a>
<a class="bmacrdc" href="https://www.buymeacoffee.com/reddelacruzdev" target="blank">
<img src="https://uploads-ssl.webflow.com/638ad076698caa5b223b1bc6/63e4d944f470fc036178c8bb_rdc%20red%20dela%20cruz%20buy%20me%20a%20coffee%202.png">
</a>
</div>
<div class="rpb-text">
<h3>What is the lorem ipsum?</h3>
<p>Have you ever read a webpage or document that used this text without paying much attention to it? The lorem ipsum is a placeholder text used in publishing and graphic design. This filler text is a short paragraph that contains all the letters of the alphabet. The characters are spread out evenly so that the reader’s attention is focused on the layout of the text instead of its content. Many software programs and applications have made it their default dummy text. Since the lorem ipsum is always used as a placeholder text, its use indicates that this is not a final version of a document, thus helping to avoid unnecessary printing.</p>
<h3>Where does it come from?</h3>
<p>The lorem ipsum is based on De finibus bonorum et malorum, a Latin text written by Cicero in 45 BC. Typographers and printers have used passages from this work for formatting since the 16th century. Many words have been added or modified over the centuries. As a result, the lorem ipsum is no longer considered Latin, even though it looks a lot like it.</p>
<p>The lorem ipsum gets its name from the Latin phrase Neque porro quisquam est qui dolorem ipsum quia dolor sit amet. which translates to “Nor is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain.”</p>
<h3>How is it Generated?</h3>
<p>A wide range of online generators can be used to create the lorem ipsum with a single click. Here’s one to try out for your next project: https://loremipsum.io/. There’s a generator for the classic lorem ipsum, as well as for more humorous placeholder texts: hipster ipsum, zombie ipsum, pokeipsum and many more!</p>
<p>Some versions of Microsoft Word also generate the text using the =lorem() function. Just type it in your Word document and you will get this paragraph:</p>
<em>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna. Nunc viverra imperdiet enim. Fusce est. Vivamus a tellus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci. Aenean nec lorem. In porttitor. Donec laoreet nonummy augue. Suspendisse dui purus, scelerisque at, vulputate vitae, pretium mattis, nunc. Mauris eget neque at sem venenatis eleifend. Ut nonummy.</em>
<p>Good luck on your next layout!</p>
</div>
</div>
* {
margin: 0;
font-family: 'Montserrat';
}
h1 {text-align: center}
p {margin: 20px 0}
h3 {margin-bottom: 10px}
.rpb-main,
.rpb-header {
display: flex;
flex-flow: column;
}
.rpb-main {
position: relative;
height: 100%;
align-items: center;
justify-content: center;
}
.rpb-header {
background-color: #108c69;
color: #fff;
padding: 6% 5% 4%;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 5%;
}
.rpb-text {
width: 90%;
max-width: 700px;
margin-inline: auto;
}
.rp-bar {
height: 10px;
position: fixed;
top: 0;
left: 0;
width: 100%;
}
.rp-bar-inner {
background-color: #0fcc9b;
height: 100%;
width: 0%;
}
.rpb-header img {
width: 70px;
filter: invert(1) saturate(0) brightness(1.2);
}
.rdc-credits {
font-weight:900;
color: #fff;
font-size: 20px;
margin: 40px 0 10px;
}
const bar = document.querySelector('.rp-bar-inner')
const article = document.querySelector('.rpb-main')
const moveProgressBar = function () {
// This means: the current Y position when you scroll divided by the height of entire article minus the height of the 'viewer'
// We subtracted the height of the viewer or the window itself because we don't want it to be part of the computation since that is the part that is already showing and no longer need to be scrolled.
const yPosition = (window.scrollY) / (article.clientHeight-window.innerHeight)
// We then multiply the answer by 100 to get the percentage and that will be the width
// Since this is a scroll event listener, it updates the width as the article scrolls
const barPercentage = yPosition*100
bar.style.width = `${barPercentage}%`
}
window.addEventListener('scroll', moveProgressBar)
Also see: Tab Triggers