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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.
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.
If the stylesheet 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 CSS 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.
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.
<div class="container">
<article class="post">
<header>
<h1 class="post-title">
A Catchy title here
</h1>
<div class="post-meta">
<time datetime="2019-05-25">May 25, 2019</time>
</div>
</header>
<div class="post-content">
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Optio, distinctio dolores accusantium nostrum alias perspiciatis molestiae voluptate vel expedita qui. Dolorem consectetur tempore atque ab corrupti, facilis nisi molestiae molestias!</p>
<p>Aliquam nisl urna, auctor sit amet dictum eget, maximus vitae metus. Integer vitae semper orci. Vestibulum tristique placerat velit id porta. Suspendisse sed porta tellus, sed dapibus ipsum. Nunc ac sem mi. Donec ac diam sit amet nunc lobortis gravida ut eu ligula. Morbi euismod mauris erat, quis viverra augue eleifend ac. Pellentesque nec dui ut eros aliquam molestie volutpat vel nibh. In non dictum turpis. Etiam molestie nibh non eleifend dapibus. Pellentesque elementum convallis efficitur. Morbi nec ex sed erat viverra iaculis a eget urna. Vestibulum tincidunt ipsum nulla, vel sagittis lorem accumsan tempor.</p>
<p>Ut pellentesque aliquet consectetur. Phasellus tempor diam ligula, id lobortis mauris scelerisque nec. Praesent et odio ut ipsum maximus pellentesque a vitae eros. Mauris aliquam mauris non velit elementum, sed pellentesque lacus tristique. Fusce vitae auctor metus. Sed blandit dui sit amet aliquet tempus. Donec scelerisque lacus leo, ac fermentum nisi feugiat a.</p>
<p>Nam fringilla erat vitae arcu lacinia, ac pulvinar erat faucibus. Mauris viverra id magna quis pulvinar. Aenean ut sodales enim. Morbi vehicula, turpis ac volutpat iaculis, est risus pharetra diam, et pulvinar tellus massa et nunc. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Etiam sit amet egestas nulla. Donec aliquet nulla eu tortor gravida posuere. Donec eget augue congue, scelerisque nisi eu, molestie ipsum. Suspendisse tincidunt elementum consectetur.</p>
<p>In lacinia sem vel erat egestas, et ultricies lectus sodales. Suspendisse ut cursus magna. Mauris fermentum at magna sagittis interdum. Proin interdum hendrerit blandit. Mauris consequat, nibh vel sollicitudin laoreet, arcu massa dictum velit, eget ultrices mi justo ut risus. Ut non consequat nisl. Morbi fermentum, leo vitae vestibulum euismod, tortor elit condimentum mauris, eget scelerisque sem tortor non nibh. Donec eu tortor luctus, sagittis mauris sed, elementum mi. Nulla velit leo, lobortis eu semper sed, aliquam eu tellus. Vestibulum nec fringilla lorem, eu rhoncus felis.</p>
<p>Sit amet consectetur, adipisicing elit. Quisquam delectus officia, suscipit provident sapiente sint recusandae exercitationem magnam ut tenetur! Totam, perspiciatis. Sed, exercitationem minus quo quidem rem asperiores id.</p>
<p>In lacinia sem vel erat egestas, et ultricies lectus sodales. Suspendisse ut cursus magna. Mauris fermentum at magna sagittis interdum. Proin interdum hendrerit blandit. Mauris consequat, nibh vel sollicitudin laoreet, arcu massa dictum velit, eget ultrices mi justo ut risus. Ut non consequat nisl. Morbi fermentum, leo vitae vestibulum euismod, tortor elit condimentum mauris, eget scelerisque sem tortor non nibh. Donec eu tortor luctus, sagittis mauris sed, elementum mi. Nulla velit leo, lobortis eu semper sed, aliquam eu tellus. Vestibulum nec fringilla lorem, eu rhoncus felis.</p>
<p>Quisquam delectus officia, suscipit provident sapiente sint recusandae exercitationem magnam ut tenetur! Totam, perspiciatis. Sed, exercitationem minus quo quidem rem asperiores id.</p>
<a href="" class="unsubscribe">Unsubscribe/Sign Out</a>
</div>
<div class="actions">
<p>Sign in or subscribe to continue reading</p>
<div class="links">
<a href="">SUBSCRIBE</a>
<a href="">SIGN IN</a>
</div>
</div>
</article>
</div>
<footer>
<div class="container">
<small>Made with <span>❤</span> by <a href="http://georgemartsoukos.com/" target="_blank">George Martsoukos</a>
</small>
</div>
</footer>
/* RESET STYLES
–––––––––––––––––––––––––––––––––––––––––––––––––– */
* {
padding: 0;
margin: 0;
}
a {
color: inherit;
text-decoration: none;
}
body {
background: #acacac;
font: 20px/1.2 'Courier New', serif;
margin: 1rem 0;
}
.post {
background: white;
padding: 2rem;
}
.post-title {
margin-bottom: 0.3rem;
}
.post-meta {
font-size: 1rem;
margin-bottom: 2rem;
}
.post-content {
position: relative;
}
.post-content p + p,
.unsubscribe {
margin-top: 2rem;
}
.unsubscribe {
font-weight: bold;
display: block;
}
.container {
max-width: 800px;
margin: 0 auto;
padding: 0 10px;
}
.post-content p:nth-child(2)::before,
.post-content p:nth-child(2)::after,
.actions {
display: none;
}
/* NOT MEMBER
–––––––––––––––––––––––––––––––––––––––––––––––––– */
.not-member .post-content p:nth-child(2) {
position: relative;
}
.not-member .post-content p:nth-child(2) ~ * {
display: none;
}
.not-member .post-content p:nth-child(2)::before,
.not-member .post-content p:nth-child(2)::after,
.not-member .actions {
display: block;
}
.not-member .post-content p:nth-child(2)::before,
.not-member .post-content p:nth-child(2)::after {
content: '';
position: absolute;
bottom: 0;
left: 0;
right: 0;
}
.not-member .post-content p:nth-child(2)::before {
background: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/162656/padlock.svg) no-repeat center;
z-index: 1;
height: 24px;
}
.not-member .post-content p:nth-child(2)::after {
background: linear-gradient(rgba(255,255,255,0.18) 18%, rgba(255,255,255,0.36) 36%, rgba(255,255,255,0.54) 54%, rgba(255,255,255,0.72) 72%, rgba(255,255,255,0.9) 90%);
height: 100%;
}
.not-member .actions {
font-weight: bold;
text-align: center;
margin-top: 2rem;
}
.not-member .links {
display: grid;
grid-gap: 1rem;
grid-template-columns: 1fr 1fr;
margin-top: 1rem;
}
.not-member .links a {
background: firebrick;
color: white;
padding: 0.5rem 0;
transition: background 0.3s;
}
.not-member .links a:hover {
background: #9d1e1e;
}
/* FOOTER
–––––––––––––––––––––––––––––––––––––––––––––––––– */
footer {
font-size: 1rem;
text-align: right;
margin-top: 1rem;
}
footer span {
color: #e31b23;
}
// we simulate that someone signs in or registers if he/she clicks on the call-to-action links
const links = document.querySelectorAll(".not-member .links a");
const unsubscribe = document.querySelector(".unsubscribe");
for (const link of links) {
link.addEventListener("click", e => {
e.preventDefault();
document.documentElement.classList.remove("not-member");
});
}
unsubscribe.addEventListener("click", e => {
e.preventDefault();
document.documentElement.classList.add("not-member");
});
Also see: Tab Triggers