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">
<div class="Subscribe">
<h3>Subscribe to our newsletter</h3>
<p>Weekly animation tutorials delivered straight to your inbox</p>
<form action="#">
<input type="text" placeholder="Email Address" />
<button>Subscribe</button>
</form>
<div class="Loading">
<div class="LoadingDot"></div>
<div class="LoadingDot"></div>
<div class="LoadingDot"></div>
<div class="LoadingDot"></div>
<span>Subscribing</span>
</div>
<div class="Complete">
<div class="Tick">
<svg width="32px" height="25px" viewBox="0 0 32 25">
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="Artboard" transform="translate(-384.000000, -217.000000)" fill-rule="nonzero" fill="#FFFFFF">
<g id="Group" transform="translate(360.000000, 189.000000)">
<path d="M27.4142136,40.5857864 C26.633165,39.8047379 25.366835,39.8047379 24.5857864,40.5857864 C23.8047379,41.366835 23.8047379,42.633165 24.5857864,43.4142136 L34,52.8284271 L55.4142136,31.4142136 C56.1952621,30.633165 56.1952621,29.366835 55.4142136,28.5857864 C54.633165,27.8047379 53.366835,27.8047379 52.5857864,28.5857864 L34,47.1715729 L27.4142136,40.5857864 Z" id="Path-2"></path>
</g>
</g>
</g>
</svg>
</div>
<h4>Thank you for subscribing</h4>
<span>You will receive a confirmation email shortly</span>
</div>
</div>
<small>This form is an animation demo and will not store any provided data.</small>
</div>
@import url('https://fonts.googleapis.com/css?family=Open+Sans:400,600');
body, html {
height: 100%;
font-family: 'Open Sans', sans-serif;
}
* {
box-sizing: border-box;
}
body {
display: flex;
align-items: center;
justify-content: center;
background-color: #F5F3F9;
}
.Container {
width: 360px;
}
.Subscribe {
height: 250px;
padding: 30px;
overflow: hidden;
position: relative;
border-radius: 6px;
margin-bottom: 20px;
background-color: white;
box-shadow: 0 6px 10px 0 rgba(149,144,179,0.15),
0 15px 50px 0 rgba(182,182,224,0.10);
}
.Subscribe::after {
width: 150%;
height: 130px;
content: "";
z-index: 1;
position: absolute;
bottom: -20px;
left: -25%;
transform: rotate(-5deg);
background-color: #F9F9FC;
transition: transform 1s cubic-bezier(0.2, 0, 0, 1);
}
.Subscribe h3 {
color: #4F20FF;
font-size: 22px;
margin-bottom: 15px;
transition: opacity 900ms 150ms cubic-bezier(0.2, 0, 0, 1), transform 900ms 150ms cubic-bezier(0.2, 0, 0, 1);
}
.Subscribe p {
color: #827C8C;
font-size: 15px;
line-height: 24px;
margin-bottom: 30px;
transition: opacity 900ms 100ms cubic-bezier(0.2, 0, 0, 1), transform 900ms 100ms cubic-bezier(0.2, 0, 0, 1);
}
.Subscribe form {
z-index: 2;
left: 20px;
width: 320px;
height: 46px;
bottom: 25px;
overflow: hidden;
position: absolute;
border-radius: 4px;
background: #FFFFFF;
box-shadow: 0 3px 6px 0 rgba(149,144,179,0.20);
transition: transform 600ms cubic-bezier(0.2, 0, 0, 1);
}
.Subscribe form::after {
top: 0;
content: "";
width: 30px;
height: 100%;
right: 110px;
position: absolute;
background: linear-gradient(90deg, rgba(white, 0), rgba(white, 1))
}
.Subscribe form input[type=text] {
border: none;
width: 100%;
height: 100%;
outline: none;
font-size: 15px;
padding: 0 110px 0 20px;
font-family: 'Open Sans', sans-serif;
}
.Subscribe form button {
top: 0;
right: 0;
padding: 0;
cursor: pointer;
outline: none;
width: 110px;
border: none;
height: 100%;
color: #5224FF;
font-size: 15px;
position: absolute;
background-color: white;
transition: color 500ms;
&:hover { color: #1A0373; }
}
.Loading {
left: 0;
opacity: 0;
z-index: 0;
width: 100%;
bottom: 50px;
position: absolute;
text-align: center;
potiner-events: none;
transition: opacity 900ms 0s cubic-bezier(0.2, 0, 0, 1), transform 900ms 0s cubic-bezier(0.2, 0, 0, 1);
.LoadingDot {
width: 6px;
opacity: 0;
height: 6px;
margin: 0 1px;
border-radius: 50%;
display: inline-block;
background-color: #B6B6CF;
}
.LoadingDot:nth-child(1) {
animation: loading 2s 0ms infinite;
}
.LoadingDot:nth-child(2) {
animation: loading 2s 200ms infinite;
}
.LoadingDot:nth-child(3) {
animation: loading 2s 400ms infinite;
}
.LoadingDot:nth-child(4) {
animation: loading 2s 600ms infinite;
}
span {
color: #B6B6CF;
display: block;
font-size: 12px;
margin-top: 15px;
}
}
@keyframes loading {
0% { opacity: 0; transform: scale(0.5) }
33% { opacity: 1; transform: scale(1) }
66% { opacity: 0; transform: scale(0.5)}
}
.Complete {
left: 0;
top: 50px;
width: 100%;
padding: 0 30px;
text-align: center;
position: absolute;
.Tick {
width: 80px;
height: 80px;
border-radius: 50%;
margin-bottom: 30px;
display: inline-block;
background-color: #4F20FF;
svg {
opacity: 0;
margin-top: 28px;
transform: scale(0.5);
transition: opacity, 400ms 500ms, transform 300ms 500ms cubic-bezier(0.2, 0, 0, 1.2);
}
opacity: 0;
transform: scale(.5);
transition:
opacity 600ms 200ms,
transform 600ms 200ms;
}
h4 {
font-size: 14px;
font-weight: 600;
margin-bottom: 10px;
opacity: 0;
transform: translateY(-15px);
transition:
opacity 600ms 450ms,
transform 600ms 450ms;
}
span {
opacity: 0;
color: #827C8C;
display: block;
font-size: 14px;
transform: translateY(-15px);
transition:
opacity 600ms 400ms,
transform 600ms 400ms;
}
}
// loading state
.Subscribe--loading,
.Subscribe--complete {
form { transform: translateY(100px) }
&::after {
transform: rotate(0) translateY(100px);
}
.Loading {opacity: 1; pointer-events: all }
}
.Subscribe--complete {
.Loading { opacity: 0; transform: translateY(100px) }
h3 { transform: translateY(100px); opacity: 0; }
p { transform: translateY(100px); opacity: 0; }
.Complete .Tick {
opacity: 1;
transform: scale(1);
}
.Complete .Tick svg {
opacity: 1;
transform: scale(1);
}
.Complete h4,
.Complete span {
opacity: 1;
transform: translateY(0);
}
}
.Container small {
width: 100%;
display: block;
color: #B6B6CF;
font-size: 14px;
padding: 0 30px;
line-height: 22px;
text-align: center;
}
const s = document.querySelector('.Subscribe')
const b = document.querySelector('button')
b.addEventListener('click', (e) => {
e.preventDefault()
s.classList.toggle('Subscribe--loading')
setTimeout(() => {
s.classList.remove('Subscribe--loading')
s.classList.toggle('Subscribe--complete')
}, 2000)
setTimeout(() => {
s.classList.remove('Subscribe--complete')
}, 5000)
})
class Subscribe extends React.Component {
render() {
return (
<div>Subscribe</div>
)
}
}
// ReactDOM.render(
// <Subscribe />,
// document.getElementById('subscribe')
// )
Also see: Tab Triggers