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.
.phone
.screen
.notification Give it up man, she's π»ing you
.header Future Wife
.texts
.blocker
.text I had a good time the other day!
.text Been thinking about you π
.text How was your day?
.text π§
.text Wanna get dinner?
.text Lunch?
.text Breakfast?
.text Coffee?
.text π§
.text How was work?
.text I saw a pretty cloud today!
.text You're prettier...
.text Phone dead?
.text π§
.text Miss u
.keyboard
.input
.row qwertyuiop
.row asdfghjkl
.row zxcvbnm
.row
.victim
.head
.eyes
.eye
.eye
.tear
.mouth
.body
.arm.left
.arm.right
.mobile
.foot.left
.foot.right
$white: #fff;
$black: #272526;
$lightgray: #EFEFEF;
$lightpurple: #948FB3;
$purple: #6F58D1;
$darkpurple: #2B2067;
$lightpink: #FFBEFA;
$pink: #F2389C;
$orange: #FE8771;
$blue: #1CA1F2;
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
body {
background: $lightpink;
font-family: 'Lato', sans-serif;
}
.phone {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: $black;
width: 250px;
height: 420px;
border-radius: 20px;
&::after {
display: block;
content: '';
position: absolute;
left: 50%;
bottom: 10px;
transform: translateX(-50%);
width: 15px;
height: 15px;
border: 3px solid #fff;
border-radius: 50%;
}
.screen {
display: flex;
flex-direction: column;
justify-content: space-between;
margin: 40px auto 0;
background: $white;
width: 220px;
height: 340px;
border-radius: 5px;
.notification {
position: absolute;
left: 50%;
transform: translate(-50%, 3px);
padding: 10px;
width: 86%;
height: 60px;
background: rgba(255, 255, 255, .95);
border: 1px solid $lightgray;
border-radius: 5px;
box-shadow: 0 5px 5px -5px $purple;
box-sizing: border-box;
font-size: 14px;
opacity: 0;
z-index: 20;
animation: new-notification 10s;
animation-delay: 15s;
&::before {
display: block;
content: 'Buddy';
font-weight: bold;
}
}
.header {
width: 100%;
height: 45px;
padding: 12px;
background: linear-gradient(135deg, $purple 55%, $purple 55%, $darkpurple 160%);
box-sizing: border-box;
color: $white;
font-weight: bold;
text-align: center;
}
.texts {
display: flex;
flex-direction: column;
justify-content: flex-end;
padding: 5px;
width: 100%;
height: 170px;
background: linear-gradient(to bottom, $white 0%, $white 75%, $lightgray 120%);
box-sizing: border-box;
overflow: hidden;
.blocker {
width: 100%;
height: 150px;
background: transparent;
}
.text {
visibility: visible;
opacity: 1;
align-self: flex-end;
margin: 3px 3px 0;
padding: 5px;
max-width: 80%;
background: $pink;
border-top-left-radius: 8px;
border-bottom-left-radius: 8px;
box-sizing: border-box;
box-shadow: 0 3px 5px -3px $pink;
color: $white;
animation: text-bubble 10s cubic-bezier(.5, 0, .5, 1) backwards;
&:first-child {
border-top-right-radius: 8px;
}
&:last-child {
border-bottom-right-radius: 8px;
}
}
// ------------
@for $i from 2 through 16 {
.text {
&:nth-child(#{$i}) {
animation-delay: ($i * 2) - 2s;
}
}
}
// ------------
}
.keyboard {
height: 125px;
background: $darkpurple;
color: $white;
font-size: 16px;
.input {
display: flex;
align-items: center;
justify-content: space-around;
width: 100%;
height: 35px;
background: white;
&::before, &::after {
display: block;
}
&::before {
content: 'Refresh to watch again!';
width: 180px;
height: 20px;
padding: 0 5px;
border: 2px solid $lightgray;
border-radius: 20px;
box-sizing: border-box;
color: $black;
font-size: 12px;
animation: type-refresh 4s backwards;
animation-delay: 36s;
}
&::after {
content: 'β¬';
width: 20px;
height: 20px;
padding: 0px 4.5px;
background: $pink;
border-radius: 50%;
box-sizing: border-box;
font-size: 12px;
text-align: center;
}
}
.row {
position: relative;
width: 100%;
margin-left: 6px;
letter-spacing: 12px;
text-align: center;
&:last-child {
position: relative;
margin: 5px auto;
width: 90px;
height: 22px;
background: $lightpurple;
border-radius: 2px;
font-size: 12px;
&::before, &::after {
display: inline-block;
position: relative;
margin-top: 2px;
color: $lightpurple;
letter-spacing: 0;
}
&::before {
content: '123';
left: -60px;
}
&::after {
content: 'return';
right: -65px;
}
}
}
}
}
}
@keyframes text-bubble {
0% {
visibility: hidden;
opacity: 0;
max-height: 0px;
margin: 0;
padding: 0;
transform: scale(0.6);
}
9% {
padding: 5px;
margin: 3px;
visibility: visible;
}
10% {
opacity: 1;
max-height: 170px;
transform: scale(1);
}
100% {
opacity: 1;
max-height: 170px;
transform: scale(1);
}
}
@keyframes new-notification {
0% {
opacity: 0;
transform: translate(-50%, -10px);
}
5% {
opacity: 1;
transform: translate(-50%, 3px);
}
50% {
opacity: 1;
transform: translate(-50%, 3px);
}
55% {
opacity: 0;
transform: translate(-50%, -10px);
}
100% {
opacity: 0;
transform: translate(-50%, -10px);
}
}
@keyframes type-refresh {
0% {
content: '';
}
1% {
content: 'R';
}
2% {
content: 'Re';
}
3% {
content: 'Ref';
}
4% {
content: 'Refr';
}
5% {
content: 'Refre';
}
6% {
content: 'Refres';
}
7% {
content: 'Refresh';
}
8% {
content: 'Refresh t';
}
9% {
content: 'Refresh to';
}
10% {
content: 'Refresh to w';
}
11% {
content: 'Refresh to wa';
}
12% {
content: 'Refresh to wat';
}
13% {
content: 'Refresh to watc';
}
14% {
content: 'Refresh to watch';
}
15% {
content: 'Refresh to watch a';
}
16% {
content: 'Refresh to watch ag';
}
17% {
content: 'Refresh to watch aga';
}
18% {
content: 'Refresh to watch agai';
}
19% {
content: 'Refresh to watch again';
}
20% {
content: 'Refresh to watch again!';
}
}
////////// ---- Victim ---- //////////
.victim {
position: absolute;
bottom: 0;
right: 10%;
.head {
position: relative;
display: flex;
width: 140px;
height: 120px;
background: $black;
border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
z-index: 5;
&::before, &::after {
display: block;
content: '';
position: relative;
top: 25px;
width: 60%;
height: 75%;
background: $white;
border-radius: 70% 70% 70% 70% / 70% 70% 70% 70%;
}
&::before {
left: 25px;
transform: rotate(-50deg);
}
&::after {
right: 25px;
transform: rotate(50deg);
}
.eyes {
display: flex;
justify-content: space-between;
position: absolute;
top: 65px;
left: 50%;
transform: translateX(-50%);
width: 45%;
z-index: 10;
.eye {
position: relative;
width: 10px;
height: 6px;
border: 4px solid $black;
border-top: 0;
border-bottom-left-radius: 15px;
border-bottom-right-radius: 15px;
.tear {
position: relative;
top: 3px;
right: -10px;
background: $blue;
width: 6px;
height: 8px;
border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
opacity: 0;
animation: tear 1s infinite;
animation-delay: 14s;
}
}
}
.mouth {
position: absolute;
bottom: 30px;
left: 50%;
transform: translateX(-50%);
width: 20px;
height: 20px;
background: $orange;
border-radius: 50% 50% 50% 50% / 30% 30% 60% 60%;
z-index: 10;
}
}
.body {
position: relative;
margin: -70px auto auto;
width: 120px;
height: 140px;
background: $black;
border-radius: 50% 50% 50% 50% / 60% 60% 20% 20%;
&::before {
display: block;
content: '';
position: absolute;
bottom: 2px;
left: 50%;
transform: translateX(-50%);
width: 80%;
height: 60%;
background: $white;
border-radius: 50% 50% 50% 50% / 60% 60% 20% 20%;
}
.arm {
position: absolute;
bottom: 50px;
width: 55px;
height: 20px;
background: $black;
z-index: 15;
&.left {
left: 5px;
border-radius: 50% 80% 80% 50% / 50% 50% 50% 50%;
transform: rotate(20deg);
transform-origin: left center;
animation: left-arm-wiggle 2s infinite;
}
&.right {
right: 5px;
border-radius: 80% 50% 50% 80% / 50% 50% 50% 50%;
transform: rotate(-20deg);
transform-origin: right center;
animation: right-arm-wiggle 2s infinite;
}
}
.mobile {
position: absolute;
left: 50%;
transform: translateX(-50%);
bottom: 30px;
width: 25px;
height: 40px;
background: $black;
box-shadow: 0 -3px 6px 2px $lightpurple;
border-radius: 3px;
z-index: 10;
animation: phone-wiggle 2s infinite;
transform-origin: center center;
}
.foot {
position: absolute;
bottom: 0;
width: 40px;
height: 15px;
background: $orange;
border-radius: 50px;
border-bottom-left-radius: 6px;
border-bottom-right-radius: 6px;
&.left {
left: 10px;
}
&.right {
right: 10px;
}
}
}
}
@keyframes tear {
0% {
top: 3px;
left: 5px;
opacity: 0;
}
20% {
top: 8px;
left: 5px;
transform: rotate(-20deg);
}
50% {
left: 10px;
opacity: 1;
}
85% {
top: 30px;
left: 8px;
transform: rotate(20deg);
}
100% {
top: 30px;
opacity: 0;
}
}
@keyframes phone-wiggle {
0% {
transform: translateX(-50%) rotate(0deg);
}
10% {
transform: translateX(-50%) rotate(2deg);
}
20% {
transform: translateX(-50%) rotate(0deg);
}
30% {
transform: translateX(-50%) rotate(-2deg);
}
50% {
transform: translateX(-50%) rotate(0deg);
}
70% {
transform: translateX(-50%) rotate(2deg);
}
80% {
transform: translateX(-50%) rotate(0deg);
}
90% {
transform: translateX(-50%) rotate(-2deg);
}
100% {
transform: translateX(-50%) rotate(0deg);
}
}
@keyframes left-arm-wiggle {
0% {
transform: rotate(20deg);
}
10% {
transform: rotate(18deg);
}
20% {
transform: rotate(20deg);
}
30% {
transform: rotate(22deg);
}
50% {
transform: rotate(20deg);
}
70% {
transform: rotate(22deg);
}
80% {
transform: rotate(20deg);
}
90% {
transform: rotate(18deg);
}
100% {
transform: rotate(20deg);
}
}
@keyframes right-arm-wiggle {
0% {
transform: rotate(-20deg);
}
10% {
transform: rotate(-22deg);
}
20% {
transform: rotate(-20deg);
}
30% {
transform: rotate(-18deg);
}
50% {
transform: rotate(-20deg);
}
70% {
transform: rotate(-18deg);
}
80% {
transform: rotate(-20deg);
}
90% {
transform: rotate(-22deg);
}
100% {
transform: rotate(-20deg);
}
}
Also see: Tab Triggers