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.
.container
- var br = '<br>';
h1.text made with!{br}css pawers
.puppy
.body-s
.body
.chest
.foot-l
.foot-r
.base
.leg-l
.leg-r
.paw-l
.paw-r
.mask
.scarf
.head
.ear-l
.ear-lf
.ear-r
.face
.face__s4
.face__s5
.face__s6
.face__s7
.mouth-b
.tongue
.mouth-l
.mouth-r
.chin
.face__s2
.face__s3
.face__s1
.nose
.eye-l
.eye-c
#eye-r.eye-r
#eye-r2.eye-r2.is-eye-hidden
$white: #ffffff;
$white-s: #b7bed4;
$red: #ec1c24;
$red-s: #c01e33;
$brown-l: #fcd7a9;
$brown: #f99b28;
$brown-s: #b3773d;
$border: #102770;
$pink: #f02f84;
$bg: #cf9ef5;
*,
*::after,
*::before {
margin: 0;
padding: 0;
box-sizing: border-box;
user-select: none;
-webkit-tap-highlight-color: transparent;
appearance: none;
}
/***********************/
/***********************/
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
width: 100%;
cursor: pointer;
overflow: hidden;
background-color: $bg;
}
/***********************/
.container {
display: flex;
justify-content: center;
align-items: center;
width: 60vw;
height: 45vw;
position: relative;
}
.text {
position: absolute;
left: 0;
top: 5vw;
font-size: 2.35vw;
font-family: "KoHo", sans-serif;
line-height: 1.2;
letter-spacing: 0.025vw;
text-transform: uppercase;
text-shadow: 0.35vw 0.15vw 0.1vw darken($bg, 10);
color: $white;
}
.puppy {
position: relative;
width: 29vw;
height: 35.5vw;
}
.head {
position: absolute;
top: 0;
left: 4.5vw;
width: 22.9vw;
height: 26.5vw;
animation: head-r 1500ms linear infinite alternate,
head-t 350ms linear infinite alternate;
}
@keyframes head-r {
0%,
30% {
transform: rotateZ(-2deg);
}
50%,
70%,
100% {
transform: rotateZ(1deg);
}
}
@keyframes head-t {
to {
top: 0.2vw;
}
}
.ear-l,
.ear-r {
display: flex;
justify-content: center;
align-items: center;
position: absolute;
top: 0;
width: 8vw;
height: 20vw;
border-radius: 50%;
border: 0.6vw solid $border;
box-shadow: inset -0.3vw 0.2vw 0 $brown-l;
background-color: $brown;
&::before {
content: "";
position: absolute;
width: 75%;
height: 80%;
border-radius: 50%;
border: 0.65vw solid $border;
box-shadow: -0.3vw -0.1vw 0 $brown-s, inset 0.4vw 0.2vw 0 darken($pink, 10);
background-color: $pink;
}
}
.ear-l {
left: 1.5vw;
transform: rotateZ(-10deg);
animation: ear-l 4000ms linear infinite alternate;
}
@keyframes ear-l {
0%,
30% {
transform: rotateZ(-10deg);
}
37%,
70% {
transform: rotateZ(-3deg);
}
77%,
100% {
transform: rotateZ(-20deg);
}
}
.ear-r {
top: 1.5vw;
right: 2vw;
transform: rotateZ(25deg);
animation: ear-r 110ms linear infinite alternate;
}
@keyframes ear-r {
to {
transform: rotateZ(23deg);
}
}
.face {
position: absolute;
top: 5.5vw;
left: 0;
width: 20vw;
height: 20vw;
transform: rotateZ(10deg);
border-radius: 48% 52% 50% 50% / 55% 55% 45% 45%;
border: 0.6vw solid $border;
box-shadow: inset 0 0.4vw 0 $brown-l, inset 0 -0.85vw 0 $white-s;
background-image: linear-gradient(to bottom, $brown 38%, $white 38%);
overflow: hidden;
&__s1 {
position: absolute;
top: 50%;
left: 50%;
transform: translateX(-50%) translateY(-90%);
width: 2.5vw;
height: 6vw;
border-top-left-radius: 50%;
border-top-right-radius: 50%;
background-color: $white;
}
&__s2,
&__s3 {
position: absolute;
top: calc(50% - 1.5vw);
width: 5vw;
height: 2vw;
background-color: $brown;
}
&__s2 {
left: calc(50% - 6.05vw);
border-bottom-left-radius: 6vw;
border-bottom-right-radius: 3vw;
}
&__s3 {
right: calc(50% - 5.95vw);
border-bottom-left-radius: 3vw;
border-bottom-right-radius: 6vw;
}
&__s4,
&__s5 {
position: absolute;
bottom: 50%;
width: 9vw;
height: 4vw;
border-top-left-radius: 2vw;
border-top-right-radius: 2vw;
border-bottom-left-radius: 1.5vw;
border-bottom-right-radius: 1.5vw;
background-color: $brown;
}
&__s4 {
border-bottom-right-radius: 2vw;
}
&__s5 {
left: calc(100% - 9vw);
border-bottom-left-radius: 1.5vw;
}
&__s6,
&__s7 {
position: absolute;
bottom: calc(50% - 1vw);
width: 2vw;
height: 1vw;
border-radius: 50%;
background-color: $white;
}
&__s6 {
left: 2.525vw;
}
&__s7 {
right: 2.525vw;
}
}
.mouth-b {
position: absolute;
left: calc(50% - 2.75vw);
top: 48%;
width: 5.5vw;
height: 6vw;
border-radius: 50%;
background-color: $border;
box-shadow: 0 0.85vw 0 $white-s;
}
.mouth-l,
.mouth-r {
position: absolute;
top: 47%;
width: 4vw;
height: 4vw;
border-radius: 50%;
border-bottom: 0.5vw solid $border;
border-left: 0.5vw solid $border;
border-top: 0.5vw solid transparent;
border-right: 0.5vw solid transparent;
background-color: $white;
}
.mouth-l {
left: calc(50% - 2vw);
transform: translateX(-50%) rotateZ(-50deg);
box-shadow: inset 0 -0.5vw 0 $white-s;
}
.mouth-r {
right: calc(50% - 6vw);
transform: translateX(-50%) rotateZ(-40deg);
box-shadow: inset 0.5vw 0 0 $white-s;
}
.tongue {
position: absolute;
top: 0;
left: calc(50% - 1.5vw);
width: 3vw;
height: 6.5vw;
border: 0.5vw solid $border;
background-color: $pink;
border-bottom-left-radius: 1.5vw;
border-bottom-right-radius: 1.5vw;
animation: tongue 175ms linear infinite alternate;
&::before {
content: "";
position: absolute;
top: 0;
left: calc(50% - 0.2vw);
width: 0.4vw;
height: 4.5vw;
border-radius: 50%;
background-color: $border;
}
}
@keyframes tongue {
to {
top: 0.15vw;
}
}
.chin {
position: absolute;
left: calc(50% - 1.125vw);
top: 80%;
width: 2.25vw;
height: 2vw;
border-radius: 50%;
border-bottom: 0.4vw solid $white-s;
}
.nose {
position: absolute;
top: 44%;
left: 50%;
transform: translateX(-50%);
width: 4vw;
height: 2.75vw;
border-top-left-radius: 1.25vw;
border-top-right-radius: 1.25vw;
border-bottom-left-radius: 2vw;
border-bottom-right-radius: 2vw;
background-color: $border;
animation: nose 175ms linear infinite alternate;
&::before {
content: "";
position: absolute;
top: 0.5vw;
left: calc(50% - 0.75vw);
width: 1.5vw;
height: 0.5vw;
border-radius: 50%;
background-color: $white;
}
}
@keyframes nose {
to {
width: 3.89vw;
}
}
.eye-c {
position: absolute;
top: 30%;
right: 4.25vw;
width: 1.85vw;
height: 3vw;
animation: eye 4000ms linear infinite alternate;
}
.eye-l,
.eye-r {
position: absolute;
width: 1.85vw;
height: 3vw;
border-radius: 50%;
background-color: $border;
&::before {
content: "";
position: absolute;
top: 20%;
right: 0.15vw;
transform: translateX(-50%);
width: 0.45vw;
height: 1.225vw;
border-radius: 50%;
background-color: $white;
}
}
@keyframes eye {
0%,
30%,
72%,
100% {
transform: translateX(-50%);
}
32%,
70% {
transform: translateX(-35%);
}
}
.eye-l {
top: 30%;
left: 6.25vw;
transform: translateX(-50%);
animation: eye 4000ms linear infinite alternate;
}
.eye-r2 {
position: absolute;
top: 38%;
width: 2vw;
height: 1vw;
border-radius: 50%;
border-top: 0.35vw solid $border;
&::before {
content: "";
position: absolute;
top: -0.3vw;
left: 0.4vw;
width: 100%;
height: 100%;
border-top: 0.35vw solid $border;
transform-origin: bottom left;
transform: rotateZ(-25deg);
border-radius: 50%;
}
}
.body-s,
.body {
position: absolute;
bottom: 0;
width: 100%;
height: 12vw;
}
.body-s {
bottom: -0.45vw;
height: 0.5vw;
border-radius: 50%;
background-color: darken($bg, 20);
}
.chest {
position: absolute;
bottom: 0;
left: 5vw;
width: 19vw;
height: 16vw;
border: 0.65vw solid $border;
border-top-left-radius: 10vw;
border-top-right-radius: 10vw;
box-shadow: inset 0 0.25vw 0 $brown-s, inset 0.25vw 0.25vw 0 $brown-s,
inset -0.25vw 0.25vw 0 $brown-s;
background-image: radial-gradient(circle at 50% 0%, $brown-s 8vw, $brown 8vw);
animation: chest 350ms linear infinite alternate;
}
@keyframes chest {
to {
height: 15.8vw;
}
}
.base {
position: absolute;
bottom: 0;
left: 3.3vw;
width: 22.4vw;
height: 6vw;
border-bottom: 0.6vw solid $border;
box-shadow: inset 0 -0.9vw 0 $brown-s;
border-top-left-radius: 1vw;
border-top-right-radius: 1vw;
background-color: $brown;
&::before {
content: "";
position: absolute;
bottom: 0;
left: calc(50% - 6vw);
width: 12vw;
height: 100%;
border-top-left-radius: 4vw;
border-top-right-radius: 4vw;
box-shadow: inset 0 -0.9vw 0 $white-s;
background-color: $white;
animation: chest-l 350ms linear infinite alternate;
}
}
@keyframes chest-l {
to {
height: 98%;
}
}
.foot-l,
.foot-r {
position: absolute;
bottom: 0;
width: 4vw;
height: 7.6vw;
border: 0.6vw solid $border;
background-color: $white;
}
.foot-l {
left: 0;
border-top-left-radius: 2vw;
border-top-right-radius: 3.1vw;
border-bottom-left-radius: 4.5vw;
border-bottom-right-radius: 0;
box-shadow: inset 0.1vw -0.9vw 0 $white-s;
animation: foot-l 800ms linear infinite alternate;
}
@keyframes foot-l {
0%,
30% {
transform: rotateZ(0);
}
50%,
100% {
transform: rotateZ(-1deg);
transform-origin: bottom right;
}
}
.foot-r {
right: 0;
border-top-left-radius: 3.1vw;
border-top-right-radius: 2vw;
border-bottom-left-radius: 0;
border-bottom-right-radius: 4.5vw;
box-shadow: inset -0.1vw -0.8vw 0 $white-s;
animation: foot-r 800ms linear infinite alternate;
}
@keyframes foot-r {
0%,
30% {
transform: rotateZ(0);
}
50%,
100% {
transform: rotateZ(1deg);
transform-origin: bottom left;
}
}
.leg-l,
.leg-r {
position: absolute;
bottom: 0;
width: 6vw;
height: 6.55vw;
border: 0.6vw solid transparent;
border-top: 0.6vw solid $border;
animation: leg 350ms linear infinite alternate;
}
@keyframes leg {
to {
height: 6.45vw;
}
}
.leg-l {
left: 2.1vw;
border-top-left-radius: 3vw;
border-top-right-radius: 2.75vw;
}
.leg-r {
right: 2.1vw;
border-top-left-radius: 2.75vw;
border-top-right-radius: 3vw;
}
.paw-l,
.paw-r {
position: absolute;
bottom: 2vw;
width: 4vw;
height: 8vw;
border-radius: 50%;
border: 0.55vw solid $border;
background-image: radial-gradient(circle at 50% 90%, $white 2vw, $brown 2vw);
}
.paw-l {
left: 9vw;
transform: rotateZ(-15deg);
box-shadow: inset 0 -0.65vw 0 $white-s,
-0.1vw 0.8vw 0 rgba(darken($white-s, 10), 0.5);
animation: paw-l 350ms linear infinite alternate;
}
@keyframes paw-l {
to {
transform: rotateZ(-15deg) translateY(0.1vw);
}
}
.paw-r {
right: 9vw;
transform: rotateZ(15deg);
box-shadow: inset 0 -0.65vw 0 $white-s,
0.1vw 0.8vw 0 rgba(darken($white-s, 10), 0.5);
animation: paw-r 350ms linear infinite alternate;
}
@keyframes paw-r {
to {
transform: rotateZ(15deg) translateY(0.1vw);
}
}
.mask {
position: absolute;
top: 2vw;
left: calc(50% - 7vw);
width: 14vw;
height: 3.5vw;
border-bottom-left-radius: 50%;
border-bottom-right-radius: 50%;
background-color: $brown;
background-image: radial-gradient(
circle at 50% -105%,
$brown-s 7vw,
$brown 7vw
);
}
.scarf {
display: flex;
justify-content: center;
position: absolute;
top: -2.1vw;
left: calc(50% - 7vw);
width: 14vw;
height: 7vw;
border-bottom-left-radius: 6vw;
border-bottom-right-radius: 6vw;
border: 0.5vw solid $border;
box-shadow: inset 0 -0.6vw 0 $red-s, 0 0.55vw 0 $brown-s;
background-color: $red;
overflow: hidden;
animation: scarf 350ms linear infinite alternate;
&::before {
content: "";
position: absolute;
bottom: 1.1vw;
left: -10%;
width: 12vw;
height: 10vw;
transform: rotateZ(20deg);
border-radius: 50%;
border-bottom: 0.4vw solid $border;
box-shadow: inset 0 -0.5vw 0 $red-s;
}
}
@keyframes scarf {
to {
top: -2vw;
}
}
.is-eye-hidden {
display: none;
}
/*
Designed by: catalyst
Original image: https://dribbble.com/catalystvibes
*/
const eyeR = document.querySelector("#eye-r");
const eyeR2 = document.querySelector("#eye-r2");
const toggleEyeFunc = () => {
eyeR.classList.toggle("is-eye-hidden");
eyeR2.classList.toggle("is-eye-hidden");
setTimeout(() => {
eyeR.classList.toggle("is-eye-hidden");
eyeR2.classList.toggle("is-eye-hidden");
}, 500);
};
document.body.addEventListener("click", toggleEyeFunc);
Also see: Tab Triggers