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 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.
<html>
<head>
</head>
<body>
<!-- Content -->
<div class="content">
<p>Lorem ipsum dolor sit amet, mei tacimates nominati ad, no possim tritani ponderum qui. Sed eirmod consectetuer in. Mei ei labores imperdiet, eu quo posse conceptam, vim viris nobis cu. Consul commodo omittantur in eos, ea everti facilisis per. Cum eu mazim diceret suavitate, est et aeque saperet persecuti, ei pertinax expetendis sed.
</p>
<p>
Has eu noster probatus aliquando, eam an esse posse essent. Vix euismod ocurreret ut, munere comprehensam usu in, vix te viris nemore ocurreret. Legere dissentiet duo at, eu vix percipit urbanitas, et sed disputando comprehensam vituperatoribus. Te mei eius atqui facer, audire feugiat voluptatibus id eam. Et sensibus partiendo vix, vis ex nonumy soleat praesent.
</p>
<p>
Nonumy placerat an mel, amet fabellas cu vim. Duo meis deserunt honestatis ne. Elitr efficiendi concludaturque cu cum, illud oblique splendide eu usu, atqui iusto nominavi sea ut. Te choro civibus his.
</p>
<p>Lorem ipsum dolor sit amet, mei tacimates nominati ad, no possim tritani ponderum qui. Sed eirmod consectetuer in. Mei ei labores imperdiet, eu quo posse conceptam, vim viris nobis cu. Consul commodo omittantur in eos, ea everti facilisis per. Cum eu mazim diceret suavitate, est et aeque saperet persecuti, ei pertinax expetendis sed.
</p>
<p>
Vix quidam integre maiorum ea, dico omnesque oporteat ea nec, eius constituam in eum. Id sea legere incorrupte. Mei facer homero facete eu, vide impedit detracto ex vix. Alia assueverit ad vel, habeo similique cu sea, elit tractatos constituto id mel. Et ius hendrerit urbanitas, et eos magna mutat.
</p>
<p>
Ei libris suscipit eum. Cu his autem viris similique. Vix simul ancillae ei, errem graeco appareat an ius. Pro ad ocurreret torquatos. Vim propriae intellegebat id.
</p>
<p>Lorem ipsum dolor sit amet, mei tacimates nominati ad, no possim tritani ponderum qui. Sed eirmod consectetuer in. Mei ei labores imperdiet, eu quo posse conceptam, vim viris nobis cu. Consul commodo omittantur in eos, ea everti facilisis per. Cum eu mazim diceret suavitate, est et aeque saperet persecuti, ei pertinax expetendis sed.
</p>
<p>
Eam iusto periculis inciderint in, eum at veniam sensibus. Cum viderer euripidis rationibus id, eam cu prompta atomorum. Nam te evertitur adversarium, aperiri epicurei ea vis, in partem diceret invenire duo. Eu vel aeterno qualisque. Nam no reque augue.
</p>
<p>
Enim duis veniam ius id, mea velit volutpat adolescens ei. Instructior disputationi mei ne. Facete corrumpit intellegebat an sit, ne pri sint facilis, duo fugit deterruisset et. Duo ne libris regione. Pri in iisque noluisse. Facete impedit invenire et eam, at tale debitis qui.
</p>
<p>
At nam mutat impetus, at eos viris dolore euripidis. Molestie iudicabit at vim, pri everti bonorum dolores ut. Erat debet habemus usu in, duo ex probatus sententiae, id erant diceret disputando ius. Feugait lucilius deterruisset sit ad, vel unum aeque definiebas at. Diam phaedrum vituperatoribus ea per, cu qui debet facilisi conceptam, pri te tantas graeco utamur.
</p>
<p>
His at elit graeco pericula, pro eu novum ludus, nec an idque tractatos. Feugiat utroque definitiones vix ei, ei mea purto prima delectus. Suas tota at per, his in ponderum salutatus. Nemore admodum omnesque sit ut, cu meliore epicurei vix. Legendos periculis mediocritatem vim no, sale persius vix no. Erant semper omnesque et vim, no mei velit senserit, partem nonumes senserit sed ea. Nibh quaeque scribentur no per, eu duo facer singulis.
</p>
<p>
Et per tritani democritum, quod nisl honestatis et eum. Vis ei legere electram complectitur, ei est quem atomorum. Has ne tota corrumpit forensibus. Magna ornatus intellegebat ex sed.
</p>
<p>Lorem ipsum dolor sit amet, mei tacimates nominati ad, no possim tritani ponderum qui. Sed eirmod consectetuer in. Mei ei labores imperdiet, eu quo posse conceptam, vim viris nobis cu. Consul commodo omittantur in eos, ea everti facilisis per. Cum eu mazim diceret suavitate, est et aeque saperet persecuti, ei pertinax expetendis sed.
</p>
<p>
Corpora omittam vivendum at est. Qui quod eleifend ut, te nam facilis epicurei antiopam. Usu possim intellegebat ea. Duo eu incorrupte complectitur vituperatoribus, eros sensibus vim ne. Ei sumo mutat fuisset vis.
</p>
<p>
Has no simul dissentias. Eum an quas apeirian eloquentiam, iuvaret vocibus denique cu his. Dicta quodsi cu duo, falli feugiat legimus pro ei, te sale putant latine ius. Vix ex error labores scripserit. No pri laoreet accusata voluptaria.
</p>
<p>
Usu ex aliquam graecis docendi. Mel scripta fabulas admodum ei, probo legimus definiebas an cum. Mel probo impetus mandamus id, aperiam mediocrem at sit, option atomorum mea an. Mazim dictas percipitur ex pri, usu et justo munere saperet.
</p>
</div>
<!-- Scroll Top -->
<button class="btn-toggle-round scroll-top js-scroll-top" type="button" title="Scroll to top">
<svg class="progress-circle" width="100%" height="100%" viewBox="-1 -1 102 102">
<path d="M50,1 a49,49 0 0,1 0,98 a49,49 0 0,1 0,-98"/>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-arrow-up" width="24" height="24" viewBox="0 0 24 24" stroke-width="1.5" stroke="cuurentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
<line x1="12" y1="5" x2="12" y2="19" />
<line x1="18" y1="11" x2="12" y2="5" />
<line x1="6" y1="11" x2="12" y2="5" />
</svg>
</button>
</body>
</html>
.scroll-top {
--ghost-accent-color: royalblue;
position: fixed;
z-index: 50;
padding: 0;
right: 20px;
bottom: 20px;
opacity: 0;
visibility: hidden;
transform: translateY(15px);
height: 46px;
width: 46px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
border-radius: 50%;
transition: all .4s ease;
border: none;
box-shadow: inset 0 0 0 2px #ccc;
color: #ccc;
background-color: #fff;
}
.scroll-top.is-active {
opacity: 1;
visibility: visible;
transform: translateY(0);
}
.scroll-top .icon-tabler-arrow-up {
position: absolute;
stroke-width: 2px;
stroke: #333;
}
.scroll-top svg path {
fill: none;
}
.scroll-top svg.progress-circle path {
stroke: #333;
stroke-width: 4;
transition: all .4s ease;
}
.scroll-top:hover {
color: var(--ghost-accent-color);
}
.scroll-top:hover .progress-circle path, .scroll-top:hover .icon-tabler-arrow-up {
stroke: var(--ghost-accent-color);
}
.content { max-width: 640px; margin: 0 auto; }
const scrollTopBtn = document.querySelector('.js-scroll-top');
if (scrollTopBtn) {
scrollTopBtn.onclick = () => {
window.scrollTo({top: 0, behavior: 'smooth'});
}
const progressPath = document.querySelector('.scroll-top path');
const pathLength = progressPath.getTotalLength();
progressPath.style.transition = progressPath.style.WebkitTransition = 'none';
progressPath.style.strokeDasharray = `${pathLength} ${pathLength}`;
progressPath.style.strokeDashoffset = pathLength;
progressPath.getBoundingClientRect();
progressPath.style.transition = progressPath.style.WebkitTransition = 'stroke-dashoffset 10ms linear';
const updateProgress = function() {
const scroll = window.scrollY || window.scrollTopBtn || document.documentElement.scrollTopBtn;
const docHeight = Math.max(
document.body.scrollHeight, document.documentElement.scrollHeight,
document.body.offsetHeight, document.documentElement.offsetHeight,
document.body.clientHeight, document.documentElement.clientHeight
);
const windowHeight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
const height = docHeight - windowHeight;
var progress = pathLength - (scroll * pathLength / height);
progressPath.style.strokeDashoffset = progress;
}
updateProgress();
const offset = 100;
window.addEventListener('scroll', function(event) {
updateProgress();
//Scroll back to top
const scrollPos = window.scrollY || window.scrollTopBtn || document.getElementsByTagName('html')[0].scrollTopBtn;
scrollPos > offset ? scrollTopBtn.classList.add('is-active') : scrollTopBtn.classList.remove('is-active');
}, false);
}
Also see: Tab Triggers