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.
<header class="centered">SomeSite.com</header>
<main>
<p>
Vel curae; arcu adipiscing posuere dictumst nostra blandit feugiat. Quisque ornare hac pharetra vulputate etiam faucibus vestibulum. Fringilla litora consectetur lectus sed lorem blandit massa duis ultrices quisque fusce. Vitae laoreet tempor eu ipsum. Neque consequat, dis ullamcorper fames dis lectus. Ornare consequat, cum elementum rutrum facilisi pellentesque aenean. Quam dignissim vivamuisis! Sed ligula rhoncus sem per et donec eu inceptos taciti consectetur. Ligula Facilisis leo ultrices fusce sociosqu felis quisque ac porta praesent? Curabitur leo aenean vehicula libero, conubia at. Convallis.
</p>
<p>
Natoque urna luctus dictumst magnis semper magna et proin nam bibendum curabitur. Duis luctus viverra adipiscing vivamus tortor duis nunc aliquet vulputate magnis iacu tempor magna? In euismod ridiculus a ornare curae; semper turpis eu feugiat ultricies commaucibus euismod blandit gravida per nulla consequat iaculis. Convallis sociosqu per; augue natoque tortor lectus non integer et dui felis. Neque, erat fusce cubilia dictum conubia tellg sem montes et. Nam senectus malesuada penatibus. Quis phasellus taciti curae; himenaeos lectus fermentum sagittis rhoncus. Accumsan.
</p>
<p>
Luctus iaculis habitasse pretium sodales blandit parturient mattis. Aliquet erat iaculis velit vestibulum elementum ad viverra. Pharetra mattis praesent sem sem et iaculis cum lectus penatibus diam egestas. Netus curae; quis tristique orci porttitor pellentesque ornare faucibus est ipsum quam aliquam. Malesuada n Ullamcorper gravida taciti sapien habitasse nostra nec! Suscipit urna commodo duis ipsum nisl eu nam gravida praesent phasellus ultricies facilisis. Natoque magnis convallis suscipit rhoncus!
</p>
<p>
Justo scelerisque, nulla lorem sed venenatis. Ultricies pretium justo eget. Mi est dictumst ad! Cursus duis sodales ultricies sollicitudin tortor ridiculus nisi tellus vulputate nisi bibendum. Per lacinia curabitur eu urna venenatis quis vivamus eleifend hit imperdiet, vivamus potenti. Consectetur accumsan accumsan cum ridiculus ipsum. Suscipit nisl ad erat risus turpis vestibulum neque sed eros diam arcu et. Et nunc faucibus feugiat etiam, dis torquent primis penatibus quam vestibulum enim. Tellus urna elementum sollicitudin diam taciti venenatis volutpat hendrerit. Consectetur turpis amet class luctus. Purus suspendisse posuere elit sem, interdum fringilla. Dolor, primis.
</p>
<div class="progressSpaceReserve">
<div class="progressHolder fixed">
<h4>Reading Progress</h4>
<div class="progressBarBG">
<div class="progressBar"></div>
</div>
</div>
</div>
</main>
<section class="comments">
<h2>Comments</h2>
<div class="comment">First!</div>
<div class="comment">This is great</div>
<div class="comment">Worst article... E V E R !!!!</div>
<div class="comment">Yo!</div>
<div class="comment">Thank you so much for this article.</div>
<div class="comment">I followed your advice exactly but it didn't work for me</div>
</section>
<section class="ads">
<h2>Bunch of Ads</h2>
<div class="adBlock">
<div class="ad"></div>
<div class="ad"></div>
<div class="ad"></div>
<div class="ad"></div>
<div class="ad"></div>
<div class="ad"></div>
</div>
</section>
<footer class="centered">
<h2>Footer<h2>
</footer>
* {
position:relative;
box-sizing:border-box;
}
body {
margin:0;
}
header {
height:25vw;
background:#07598C;
color:white;
font-size:10vw;
font-weight:800;
}
main {
padding-top:20px;
}
p {
max-width:800px;
margin-top:0;
margin-left:20px;
font-size:1.5rem;
line-height:2rem;
}
.progressSpaceReserve {
width:100%;
height:60px;
background:grey;
}
.progressHolder {
border-top:1px solid #ccc;
background:white;
width:100%;
height:60px;
bottom:0;
position:absolute;
z-index:1000;
display:flex;
align-items:center;
justify-content:space-evenly;
flex-direction:column;
}
.progressBarBG {
width:400px;
height:10px;
background:#ccc;
}
.progressBar {
width:400px;
height:10px;
background:red;
transform:scaleX(0);
transform-origin:0 0;
}
.fixed {
position:fixed;
}
h4, header, h1, h2 {
font-family:sans-serif;
}
h4 {
color:#222;
margin:0;
padding:0;
}
.centered {
display:flex;
justify-content:center;
align-items:center;
}
.comments {
padding:20px;
color:white;
font-family:sans-serif;
background:#7AA5BF;
}
h2 {
color:white;
font-size:4em;
}
.comment {
width:80%;
margin-bottom:20px;
padding:20px;
margin-left:20px;
font-size:1.5em;
color:white;
background:#022840;
border-radius: 1em;
}
.ads {
padding:20px;
background:#F2F2F2;
}
.adBlock {
display:flex;
flex-direction:row;
align-items:space-evenly;
justify-content:space-evenly;
flex-wrap:wrap;
}
.ads h2{
color:#595959;
}
.ad {
width:30vw;
height:16vw;
min-width:150px;
background:#595959;
border-radius:12px;
margin-bottom:5vw;
margin-right:5vw;
}
footer {
height:40vh;
background:#1d1d1d;
}
const progressHolder = document.querySelector(".progressHolder")
const progressBar = document.querySelector(".progressBar")
const tween = gsap.to(progressBar, {scaleX:1, ease:"none", paused:true})
ScrollTrigger.create({
trigger:"body",
start:"top top",
scrub:true,
endTrigger:"main",
end:"bottom bottom",
once:true,
onLeave:self=>{
progressHolder.classList.remove("fixed")
},
onUpdate:function(self){
if(self.progress > tween.progress()){
tween.progress(self.progress)
}
}
})
Also see: Tab Triggers