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">
<a class="box box--1">
<div class="box__background">
<div class="box__text-line box__text-line--top">
<span>Limited time</span>
</div>
<div class="box__text-line box__text-line--bottom">
<span>WEEKEND SALE EVENT</span>
</div>
</div>
<div class="box__content">
<div class="box__col">
<div class="box__title">Black <span>Friday</span></div>
<div class="box__btn">shop now</div>
</div>
<div class="box__col">
<div class="box__card card">
<div class="card__top">
21.11 - 27.11
</div>
<div class="card__title">
<span>15%</span> Electronics
</div>
<div class="card__btn">
See more
</div>
</div>
<div class="box__card card">
<div class="card__top">
25 november
</div>
<div class="card__title">
<span>35%</span> everything
</div>
<div class="card__btn">
See more
</div>
</div>
</div>
</div>
</a>
<a class="box box--2">
<svg class="box__background" viewBox="0 0 800 800" fill="none" xmlns="http://www.w3.org/2000/svg">
<path id="line1"
d="M251.994 21.5L251.995 190.5C251.995 212.591 269.903 230.5 291.995 230.5L517.5 230.5C539.592 230.5 557.5 248.409 557.5 270.5L557.5 275.5C557.5 297.591 575.409 315.5 597.5 315.5L759 315.5"
stroke="black" stroke-width="40" stroke-linecap="round" />
<path id="line2"
d="M20.5001 451L226 451C248.091 451 266 468.909 266 491L266 530C266 552.091 283.908 570 306 570L475.5 570C497.591 570 515.5 587.909 515.5 610L515.5 776.5"
stroke="black" stroke-width="40" stroke-linecap="round" />
<text fill="#fff">
<textpath startOffset="0%" text-anchor="middle" alignment-baseline="central" xlink:href="#line1">
WEEKEND SALE EVENT
<animate attributeName="startOffset" from="0%" to="100%" begin="0s" dur="6s"
repeatCount="indefinite" />
</textpath>
</text>
<text fill="#fff">
<textpath startOffset="0%" text-anchor="middle" alignment-baseline="central" xlink:href="#line1">
WEEKEND SALE EVENT
<animate attributeName="startOffset" from="0%" to="100%" begin="3s" dur="6s"
repeatCount="indefinite" />
</textpath>
</text>
<text fill="#fff">
<textpath startOffset="0%" text-anchor="middle" alignment-baseline="central" xlink:href="#line2">ONE
Day
<animate attributeName="startOffset" from="0%" to="100%" begin="0s" dur="6s"
repeatCount="indefinite" />
</textpath>
</text>
<text fill="#fff">
<textpath startOffset="0%" text-anchor="middle" alignment-baseline="central" xlink:href="#line2">
special OFFER
<animate attributeName="startOffset" from="0%" to="100%" begin="3s" dur="6s"
repeatCount="indefinite" />
</textpath>
</text>
</svg>
<div class="box__content">
get up to <span>50%</span> off
<div class="box__btn">shop now</div>
</div>
</a>
<a class="box box--3">
<svg class="box__background" viewBox="0 0 540 540" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M420 270C420 352.843 352.843 420 270 420C187.157 420 120 352.843 120 270C120 187.157 187.157 120 270 120C352.843 120 420 187.157 420 270Z"
fill="black" />
</svg>
<svg class="box__background box__text-svg" viewBox="0 0 540 540" fill="none"
xmlns="http://www.w3.org/2000/svg">
<path id="circle1"
d="M440 270C440 363.888 363.888 440 270 440C176.112 440 100 363.888 100 270C100 176.112 176.112 100 270 100C363.888 100 440 176.112 440 270Z"
stroke-width="40" />
<text>
<textPath alignment-baseline="middle" href="#circle1" stroke="none" fill="#000">
SUPER SALE • BEST OFFER • the full • SUPER SALE • SALE EVENT •
</textPath>
</text>
</svg>
<svg class="box__background box__text-svg box__text-svg--reverse" viewBox="0 0 540 540" fill="none"
xmlns="http://www.w3.org/2000/svg">
<path id="circle2" stroke="#000"
d="M480 270C480 385.98 385.98 480 270 480C154.02 480 60 385.98 60 270C60 154.02 154.02 60 270 60C385.98 60 480 154.02 480 270Z"
stroke-width="40" />
<text>
<textPath alignment-baseline="middle" href="#circle2" stroke="none" fill="#fff">
10% 70% 35% 25% 55% 80% 15% 15% 80% 10% 70% 35% 25% 5% 80% 15% 5% 80% 15%
</textPath>
</text>
</svg>
<svg class="box__background box__text-svg" viewBox="0 0 540 540" fill="none"
xmlns="http://www.w3.org/2000/svg">
<path id="circle3"
d="M520 270C520 408.071 408.071 520 270 520C131.929 520 20 408.071 20 270C20 131.929 131.929 20 270 20C408.071 20 520 131.929 520 270Z"
stroke-width="40" />
<text>
<textPath alignment-baseline="middle" href="#circle3" stroke="none" fill="#000">
$ $$ $ $$$ $ $$ $$$ $$ $ $$ $ $ $ $$ $$$ $ $$ $ $ $$$ $$ $$ $ $ $$$ $$ $$ $ $ $$$ $ $ $$ $$ $$$
$ $ $$$ $$$
</textPath>
</text>
</svg>
<div class="box__content">
get up to <span>25%</span>
<div class="box__btn">shop now</div>
</div>
</a>
<a class="box box--4">
<div class="box__content">
70%
<span>WEEKEND SALE EVENT</span>
5%
<span>the full</span>
20%
<span>SUPER SALE</span>
10%
<span>5% off</span>
<span>SALE</span>
70%
<span>SALE EVENT</span>
<span>ONE Day</span>!
10%
<span>SALE</span>
<span>the full</span>
70%! $$
<span class="box__title box__title--top">Black Friday</span>
<span>70%</span>$$!
<span>85% off</span>
<span class="box__title">shop now</span>$
<span>5% off</span>$
<span>50% OFF</span>
<span>SALE</span>
70%
<span>BEST OFFER</span>
<span>the full</span>$
30%!
<span>Limited time</span>
50%<span>off sale</span>
<span>special OFFER</span>
</div>
</a>
</div>
:root {
--color-black: black;
--color-white: white;
--color-yellow: yellow;
--color-grey: #e8e8e8;
--time: 4s;
--time-s: 0.3s;
--vw: 60vw;
@media (max-width: 768px) {
--size-height: 54px;
}
}
* {
box-sizing: border-box;
}
a {
text-decoration: none;
color: white;
}
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;800&display=swap');
html {
font-size: 1vw;
@media (max-width: 768px) {
font-size: 1.6vw;
}
}
body {
font-family: 'Montserrat', sans-serif;
min-height: 100vh;
background-color: var(--color-grey);
color: #fff;
font-size: 3rem;
line-height: 1;
font-weight: 300;
display: flex;
justify-content: center;
align-items: center;
margin: 0;
}
.container {
width: 100%;
margin: 0 auto;
display: flex;
justify-content: center;
align-items: center;
flex-wrap: wrap;
}
.box {
cursor: pointer;
position: relative;
display: inline-block;
box-sizing: border-box;
width: 30vw;
padding-bottom: 30vw;
margin: 1vw;
background-color: #7f72d2;
background-color: var(--color-yellow);
text-transform: uppercase;
font-weight: 800;
overflow: hidden;
@media (max-width: 768px) {
width: 46vw;
padding-bottom: 46vw;
}
&:hover {
.box__btn {
background-color: var(--color-yellow);
color: var(--color-black);
}
.box__background {
animation-play-state: paused;
}
}
&__title {
transition: all var(--time-s);
transform: scale(1) translateY(0);
}
&__btn {
line-height: 4vw;
text-align: center;
max-width: 80%;
padding: 0 2vw;
font-size: 1.8rem;
margin-top: 1vw;
transition: all var(--time-s);
transform: scale(1);
background-color: var(--color-black);
color: var(--color-white);
border: 1px solid var(--color-black);
}
&__background {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: auto;
}
&__content {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
padding: 2vw;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-items: center;
align-content: center;
}
&__col {
width: 50%;
height: 100%;
display: flex;
flex-direction: column;
align-content: center;
align-items: center;
justify-content: center;
}
&__text-line {
position: absolute;
font-size: 1.5rem;
text-align: center;
left: 3vw;
right: 50%;
&--top {
top: 0;
}
&--bottom {
bottom: 0;
}
span {
line-height: 3vw;
padding: 0 1.5vw;
background-color: var(--color-yellow);
}
}
&__text-svg {
transform-origin: 50% 50%;
animation: rotate normal infinite calc(var(--time-s) * 30) linear;
&--reverse {
animation: rotateReverse normal infinite calc(var(--time-s) * 50) linear;
}
}
&--1,
&--4 {
width: 60vw;
@media (max-width: 768px) {
width: 94vw;
padding-bottom: 46vw;
}
}
&--1 {
background-color: var(--color-white);
color: var(--color-black);
.box__background {
outline: 3vw solid var(--color-yellow);
outline-offset: -3vw;
height: 100%;
&:before {
content: "";
position: absolute;
border: 1px solid var(--color-black);
left: 1.5vw;
right: 1.5vw;
top: 1.5vw;
bottom: 1.5vw;
}
}
.box__content {
padding: 3vw;
}
.box__title {
text-align: center;
font-size: 5rem;
span {
display: block;
font-size: 4rem;
}
}
&:hover {}
}
&--2 {
font-size: 1.5rem;
.box__background {
top: -50%;
left: -50%;
width: 200%;
height: auto;
font-size: 24px;
}
.box__content {
color: var(--color-black);
justify-content: center;
align-items: center;
align-content: center;
flex-direction: column;
span {
display: block;
font-size: 8rem;
}
}
}
&--3 {
.box__background {
top: -20%;
left: -20%;
width: 140%;
height: auto;
font-size: 30px;
}
.box__content {
font-size: 1.5rem;
color: var(--color-white);
justify-content: center;
align-items: center;
align-content: center;
flex-direction: column;
span {
display: block;
font-size: 6rem;
}
}
.box__btn {
background-color: var(--color-white);
color: var(--color-black);
}
}
&--4 {
background-color: var(--color-black);
text-shadow:
-1px 0 0 var(--color-white),
0 -1px 0 var(--color-white),
1px 0 0 var(--color-white),
0 1px 0 var(--color-white);
color: #000;
span {
letter-spacing: 0.3vw;
animation: text var(--time) linear infinite running;
&:nth-child(2n+1) {
animation-delay: calc(var(--time) / 4);
}
&:nth-child(3n+2) {
animation-delay: calc(var(--time) / 2);
}
}
&:hover {
text-shadow:
-1px 0 0 var(--color-grey),
0 -1px 0 var(--color-grey),
1px 0 0 var(--color-grey),
0 1px 0 var(--color-grey);
span {
animation: none;
}
.box__title {
z-index: 2;
opacity: 1;
text-shadow:
-1px 0 0 var(--color-yellow),
0 -1px 0 var(--color-yellow),
1px 0 0 var(--color-yellow),
0 1px 0 var(--color-yellow);
transform: scale(1.6);
color: var(--color-yellow);
&--top {
transform: scale(1.6) translateY(-1vw);
}
}
}
}
}
.card {
position: relative;
font-size: 1.5rem;
color: var(--color-black);
border: 1px solid var(--color-black);
background-color: var(--color-grey);
margin: 3%;
height: 40%;
width: 88%;
display: flex;
flex-direction: column;
overflow: hidden;
&__top {
background-color: var(--color-black);
color: var(--color-white);
text-align: center;
line-height: 1.2;
}
&__title {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
flex: 1;
transition: all var(--time-s);
span {
padding-right: 4%;
font-size: 3rem;
}
}
&__btn {
position: absolute;
bottom: 0;
left: 0;
right: 0;
line-height: 1.2;
transition: all var(--time-s);
background-color: var(--color-yellow);
color: var(--color-black);
border-top: 1px solid var(--color-black);
text-align: center;
transform: translateY(100%);
}
&:hover {
.card__title {
transform: translateY(-1vw);
}
.card__btn {
transform: translateY(0);
}
}
}
@keyframes text {
0%,
19% {
color: var(--color-white);
}
20%,
100% {
color: var(--color-black);
}
}
@keyframes rotate {
to {
transform: rotate(360deg);
}
}
@keyframes rotateReverse {
to {
transform: rotate(-360deg);
}
}
Also see: Tab Triggers