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.
<div class="smooth-scroll">
<div class="smooth-scroll-content">
<h1>Safari Bug - fixed elements jump</h1>
<p>Just use your mouse wheel and it'll scroll at a steady pace. In Safari, as long as it's in debug mode (NOT an iframe), you'll see that the fixed elements on the left/right JUMP under heavy load! At lectus urna duis convallis convallis tellus id interdum. Vitae semper quis lectus nulla at volutpat diam ut. A lacus vestibulum sed arcu non. Et tortor at risus viverra adipiscing at in tellus integer. Magna ac placerat vestibulum lectus mauris ultrices eros in cursus. Feugiat pretium nibh ipsum consequat nisl vel pretium. Cum sociis natoque penatibus et magnis dis parturient montes nascetur. Urna molestie at elementum eu facilisis sed odio. Nunc faucibus a pellentesque sit. Enim lobortis scelerisque fermentum dui faucibus.</p>
<div class="heavy heavy">
<img src="https://r.happymonsters.com/codepen/pic3.jpg">
</div>
<p>Nisl rhoncus mattis rhoncus urna neque viverra. Nisl nunc mi ipsum faucibus vitae aliquet. Dictum fusce ut placerat orci nulla. Ut venenatis tellus in metus vulputate eu scelerisque felis. Nec feugiat in fermentum posuere urna nec tincidunt. Porttitor lacus luctus accumsan tortor posuere. Nec ullamcorper sit amet risus. Mus mauris vitae ultricies leo integer. Odio pellentesque diam volutpat commodo sed egestas egestas. Mauris nunc congue nisi vitae suscipit tellus mauris a. Ac placerat vestibulum lectus mauris ultrices eros in cursus. Et tortor consequat id porta nibh venenatis cras sed. Pretium fusce id velit ut tortor. Rutrum quisque non tellus orci. Dapibus ultrices in iaculis nunc sed augue lacus viverra vitae. Enim eu turpis egestas pretium. Quam viverra orci sagittis eu volutpat odio facilisis mauris sit. Neque sodales ut etiam sit amet nisl purus in mollis. Sed ullamcorper morbi tincidunt ornare massa eget egestas purus viverra. Diam quis enim lobortis scelerisque fermentum dui faucibus in.</p>
<div class="heavy heavy2">
<img src="https://r.happymonsters.com/codepen/pic2.jpg">
</div>
<p>Potenti nullam ac tortor vitae. Consequat semper viverra nam libero justo laoreet. Lectus vestibulum mattis ullamcorper velit. Dis parturient montes nascetur ridiculus mus. Id velit ut tortor pretium viverra suspendisse potenti. Faucibus scelerisque eleifend donec pretium vulputate sapien. Ullamcorper dignissim cras tincidunt lobortis feugiat vivamus at augue. Lacus sed turpis tincidunt id aliquet. Eleifend donec pretium vulputate sapien nec sagittis aliquam. In dictum non consectetur a erat nam at lectus. Pharetra massa massa ultricies mi quis hendrerit dolor. Volutpat commodo sed egestas egestas. Semper eget duis at tellus at urna condimentum mattis. Morbi leo urna molestie at elementum eu.</p>
<p>Tempor orci eu lobortis elementum nibh tellus molestie nunc. Bibendum est ultricies integer quis auctor elit sed vulputate. Massa sapien faucibus et molestie ac feugiat sed lectus vestibulum. Sed pulvinar proin gravida hendrerit lectus. Curabitur gravida arcu ac tortor dignissim. Ut tristique et egestas quis ipsum suspendisse ultrices gravida. Luctus accumsan tortor posuere ac ut consequat semper viverra nam. Tristique senectus et netus et malesuada fames ac turpis egestas. Gravida rutrum quisque non tellus orci. Molestie nunc non blandit massa enim nec.</p>
<div class="heavy heavy3">
<img src="https://r.happymonsters.com/codepen/pic1.jpg">
</div>
<p>Risus pretium quam vulputate dignissim suspendisse in est ante. Volutpat ac tincidunt vitae semper quis lectus nulla at volutpat. Sem integer vitae justo eget magna fermentum. Integer enim neque volutpat ac tincidunt vitae semper quis. Quis hendrerit dolor magna eget est. Viverra tellus in hac habitasse platea dictumst vestibulum rhoncus. Eget nullam non nisi est sit amet. Cras sed felis eget velit aliquet sagittis id consectetur purus. Sed tempus urna et pharetra pharetra. Ac orci phasellus egestas tellus. Aliquam faucibus purus in massa tempor nec feugiat nisl pretium. Nisi porta lorem mollis aliquam ut porttitor leo a diam. Quam quisque id diam vel quam elementum pulvinar etiam non. Vitae nunc sed velit dignissim sodales ut eu sem.</p>
<div class="heavy heavy" id="changeOne">
<img src="https://r.happymonsters.com/codepen/pic3.jpg">
</div>
<p>Nisl rhoncus mattis rhoncus urna neque viverra. Nisl nunc mi ipsum faucibus vitae aliquet. Dictum fusce ut placerat orci nulla. Ut venenatis tellus in metus vulputate eu scelerisque felis. Nec feugiat in fermentum posuere urna nec tincidunt. Porttitor lacus luctus accumsan tortor posuere. Nec ullamcorper sit amet risus. Mus mauris vitae ultricies leo integer. Odio pellentesque diam volutpat commodo sed egestas egestas. Mauris nunc congue nisi vitae suscipit tellus mauris a. Ac placerat vestibulum lectus mauris ultrices eros in cursus. Et tortor consequat id porta nibh venenatis cras sed. Pretium fusce id velit ut tortor. Rutrum quisque non tellus orci. Dapibus ultrices in iaculis nunc sed augue lacus viverra vitae. Enim eu turpis egestas pretium. Quam viverra orci sagittis eu volutpat odio facilisis mauris sit. Neque sodales ut etiam sit amet nisl purus in mollis. Sed ullamcorper morbi tincidunt ornare massa eget egestas purus viverra. Diam quis enim lobortis scelerisque fermentum dui faucibus in.</p>
<div class="heavy heavy2" id="changeTwo">
<img src="https://r.happymonsters.com/codepen/pic2.jpg">
</div>
<p>Potenti nullam ac tortor vitae. Consequat semper viverra nam libero justo laoreet. Lectus vestibulum mattis ullamcorper velit. Dis parturient montes nascetur ridiculus mus. Id velit ut tortor pretium viverra suspendisse potenti. Faucibus scelerisque eleifend donec pretium vulputate sapien. Ullamcorper dignissim cras tincidunt lobortis feugiat vivamus at augue. Lacus sed turpis tincidunt id aliquet. Eleifend donec pretium vulputate sapien nec sagittis aliquam. In dictum non consectetur a erat nam at lectus. Pharetra massa massa ultricies mi quis hendrerit dolor. Volutpat commodo sed egestas egestas. Semper eget duis at tellus at urna condimentum mattis. Morbi leo urna molestie at elementum eu.</p>
<p>Tempor orci eu lobortis elementum nibh tellus molestie nunc. Bibendum est ultricies integer quis auctor elit sed vulputate. Massa sapien faucibus et molestie ac feugiat sed lectus vestibulum. Sed pulvinar proin gravida hendrerit lectus. Curabitur gravida arcu ac tortor dignissim. Ut tristique et egestas quis ipsum suspendisse ultrices gravida. Luctus accumsan tortor posuere ac ut consequat semper viverra nam. Tristique senectus et netus et malesuada fames ac turpis egestas. Gravida rutrum quisque non tellus orci. Molestie nunc non blandit massa enim nec.</p>
<div class="heavy heavy3" id="changeThree">
<img src="https://r.happymonsters.com/codepen/pic1.jpg">
</div>
<p>Risus pretium quam vulputate dignissim suspendisse in est ante. Volutpat ac tincidunt vitae semper quis lectus nulla at volutpat. Sem integer vitae justo eget magna fermentum. Integer enim neque volutpat ac tincidunt vitae semper quis. Quis hendrerit dolor magna eget est. Viverra tellus in hac habitasse platea dictumst vestibulum rhoncus. Eget nullam non nisi est sit amet. Cras sed felis eget velit aliquet sagittis id consectetur purus. Sed tempus urna et pharetra pharetra. Ac orci phasellus egestas tellus. Aliquam faucibus purus in massa tempor nec feugiat nisl pretium. Nisi porta lorem mollis aliquam ut porttitor leo a diam. Quam quisque id diam vel quam elementum pulvinar etiam non. Vitae nunc sed velit dignissim sodales ut eu sem.</p>
</div>
</div>
<div class="fixed" id="fixedTestOne"><span>Fixed 1</span></div>
<div class="fixed" id="fixedTestTwo"><span>Fixed 2</span></div>
img {
display: block;
width: 100%;
height: 100%;
}
/* body {
height:calc(100% - 1px)
} */
/* body {
overflow-y: scroll;
overflow-x: hidden;
-webkit-overflow-scrolling: touch;
} */
.smooth-scroll {
position: relative;
/*width: calc(100% - 400px)!important;*/
/*margin-left: 150px;*/
}
.fixed {
position: fixed;
top: 0;
bottom: 0;
display: flex;
flex-flow: row nowrap;
justify-content: space-around;
align-items: center;
align-content: center;
}
#fixedTestOne {
left: 0;
width: 100px;
background-color: red;
}
#fixedTestTwo {
right: 0;
width: 200px;
background-color: blue;
}
.fixed span {
font-size: 20px;
font-weight: bold;
text-shadow: 1px 1px 2px #ffffff;
}
h1 {
font-size: 40px;
text-align: center;
margin: 30px;
}
p {
font-size: 20px;
line-height: 30px;
}
.heavy {
margin: 25px
}
.heavy1 img {
border-radius:20px;
}
.heavy2 img {
border-radius:20px;
transform: scale(.9) rotate(5deg);
}
.heavy3 img {
border-radius:20px;
transform: scale(.9) rotate(5deg);
filter: blur(5px);
}
// You MUST open this in debug mode so that it's not in an iframe! https://codepen.io/pen/debug/ExoyEyg/c0402caac3044c3f5bb85022450b059b
// Just use your mouse wheel and it'll scroll at a steady pace. In Safari, as long as it's
// in debug mode (NOT an iframe), you'll see that the fixed elements on the left/right JUMP
// intermittently under heavy load!
let images = document.querySelectorAll("img"),
y = 0;
document.addEventListener("wheel", e => {
e.preventDefault(); // don't scroll! We'll do it on the JS thread.
y += 30;
if (y > 8500) {
y = 0;
}
// filters just add a lot of load...
images.forEach(img => img.style.filter = "blur(" + (2 + Math.random() * 48) + "px)");
// now scroll by 30px via JS
window.scrollTo(0, y);
}, { passive: false });
// Note: the heavy load must be on the painting/compositor not the JS thread in order to trigger the problem.
Also see: Tab Triggers