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="container">
<h2>Notification Box <br /> <span>Inspired by <a href="https://site.uplabs.com/posts/notify-me-interface">Notify Me — Oleg Frolov</a></span></h2>
<form class="notify">
<label for="notify-email" class="notify__label" aria-label="hidden">email</label>
<input id="notify-email" class="notify__input" type="email" placeholder="email">
<button type="button" class="notify__button notify__send-button" id="send-button">Send</button>
<button type="button" class="notify__button notify__outer-button" id="outer-button">Notify Me</button>
<p id="thankyou-label" class="notify__thank-you-label">Thank You!</p>
</form>
</div>
$darksalmon: #e9967a;
* {
box-sizing: border-box;
}
*:after, *:before {
box-sizing: inherit;
}
body {
width: 100%;
height: 100%;
background-color: $darksalmon;
line-height: 1.5;
}
.container {
width: 100%;
margin: 5% auto;
padding: 1em 0;
font-size: 1.5rem;
text-align: center;
background-color: $darksalmon;
h2 {
color: white;
font-size: 1.6rem;
span {
font-size: 1.3rem;
a {
color: white;
}
}
}
}
.notify {
background: transparent;
position: relative;
margin: 0 auto;
width: 100%;
max-width: 320px;
text-align: center;
}
//hide textbox label
.notify__label {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0,0,0,0);
border: 0;
}
.notify__input {
position: relative;
top: 0px;
padding: 1em 5px;
border-radius: 30px;
transform: scaleX(0);
visibility: hidden;
width: 315px;
font-size: 0.9rem;
font-weight: 700;
line-height: 1.9;
border-color: transparent;
outline: none;
&:focus {
box-shadow: 1px 1px 3px $darksalmon inset;
}
}
.notify__button {
text-align: center;
border-radius: 15px;
background-color: transparent;
border: none;
outline: none;
}
.notify__send-button {
padding: 0.5em;
position: absolute;
top: 49%;
right:8px;
transform: translateY(-49%);
font-size: 1.3rem;
font-weight: 700;
background-color: lighten($darksalmon, 5);
color: #fefefe;
cursor: pointer;
transition: all 0.2s;
visibility: hidden;
&:hover,
&:focus {
background-color: $darksalmon;
color: white;
}
}
.notify__outer-button {
position: absolute;
top: 60%;
left: 50%;
transform: translate(-50%, -60%);
width: 60%;
padding: 1rem;
font-size: 1.3rem;
font-weight: 700;
background-color: white;
color: $darksalmon;
cursor: pointer;
box-shadow: 1px 3px 0px rgba(0,0,0, .5);
transition: color 0.2s;
&:hover,
&:focus {
color: darken($darksalmon, 10);
}
}
.notify__thank-you-label {
position: absolute;
top: -29px;
left: 50%;
transform: translateX(-50%);
width: 100%;
padding: 0.7rem;
text-align: center;
font-size: 1.5rem;
font-weight: 800;
border-radius: 25px;
background-color: white;
color: $darksalmon;
visibility: hidden;
}
//vars
const emailInput = document.querySelector("#notify-email"),
sendButton = document.querySelector("#send-button"),
thankyouLabel = document.querySelector("#thankyou-label"),
outerButton = document.querySelector("#outer-button");
//scale down the initial button, the send button
//and the thank you label, so they can be
//scaled up when they make their entrances
//in the animation
TweenMax.set([outerButton, sendButton, thankyouLabel], { scale: 0.5 });
//this tween controls the entrance of the
//first button as the page loads
TweenMax.to(outerButton, 0.5, { scale: 1, ease: Back.easeOut.config(3) });
//code that triggers the appearance of the
//text box on button click
outerButton.addEventListener("click", function() {
//The text box appears over half a second
//and is scaled up
TweenMax.to(emailInput, 0.5, {
autoAlpha: 1,
scale: 1
});
//the initial button disappears from view
TweenMax.to(this, 1, {
autoAlpha: 0
});
//the send button appears over half a second
//and it's scaled up
TweenMax.to(sendButton, 0.5, {
autoAlpha: 1,
scale: 1,
delay: 0.5,
ease: Back.easeOut.config(3)
});
});
//code triggered after clicking the send button
sendButton.addEventListener("click", function() {
//thank you label appears and starts to scale up
TweenMax.to(thankyouLabel, 1, {
autoAlpha: 1,
scale: 0.7
});
//thank you label is scaled up completely
TweenMax.to(thankyouLabel, 1, {
scale: 1
});
//the text color inside the input box changes
//to white to make it invisible
TweenMax.to(
emailInput,
0,
{
color: "#ffffff"
});
//the input box is scaled down and removed
TweenMax.to(
emailInput,
0.2,
{
scaleX: 0,
autoAlpha: 0,
delay: 0.5
});
//the send button is removed
TweenMax.to(
this,
0.3,
{
autoAlpha: 0
});
//the thank you label is scaled up on the
//X axis
TweenMax.to(thankyouLabel, 0.5, {
scaleX: 0.6,
delay: 0.5,
ease: Back.easeOut.config(3)
});
//the font-size in the thank you label
//is enlarged to make it more readable
TweenMax.to(thankyouLabel, 0.5, {
fontSize: 25,
delay: 0.5
});
});
Also see: Tab Triggers