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.
<button class="explore-menu">
<div class="beef"></div>
<svg class="cheese" viewBox="0 0 160 53">
<path d="M0.0742121 22.3328C1.05135 9.72939 11.5807 0 24.2433 0H144.841C151.675 0 157.394 5.17681 158.061 11.9668L159.974 31.4473C160.594 37.7607 150.009 44.9809 143.654 44.9541C124.599 44.8738 103.951 52.2575 84.8988 52.946C69.006 53.5202 56.2241 49.3376 40.3255 48.95C36.4794 48.8563 31.9925 48.9847 27.4027 49.2331C12.0678 50.0627 -1.11087 37.6185 0.0742121 22.3328Z" />
</svg>
<svg class="salad" viewBox="0 0 160 52">
<path d="M0 23.2943C0 10.4292 10.3289 0 23.0703 0H134C148.359 0 160 11.9259 160 26.4247C160 40.3873 149.167 51.524 135.347 51.0361C117.842 50.4181 97.0486 49.4757 91.5 49.4757C70.1294 49.4757 70.5419 52 51.5 52C42.911 52 35.0402 51.5166 27.8556 51.0969C13.391 50.252 0 37.9238 0 23.2943Z" />
</svg>
<svg class="ketchup" viewBox="0 0 160 54">
<path d="M0 25.2026C0 11.2836 11.2868 0 25.2097 0H134.912C148.768 0 160 11.229 160 25.0808C160 39.2502 148.267 50.5865 134.093 50.5825C127.22 50.5806 120.037 50.6804 114 50.9856C100.688 51.6586 93.3279 53.7853 80 53.9848C63.9475 54.225 55.0442 51.5562 39 50.9856C34.9927 50.8431 30.3922 50.7756 25.7886 50.7535C11.6411 50.6857 0 39.3462 0 25.2026Z" />
</svg>
<div class="top">Explore Menu</div>
</button>
<a class="dribbble" href="https://dribbble.com/ai" target="_blank"><img src="https://cdn.dribbble.com/assets/dribbble-ball-mark-2bd45f09c2fb58dbbfb44766d5d1d07c5a12972d602ef8b32204d28fa3dda554.svg" alt=""></a>
<a class="twitter" target="_top" href="https://twitter.com/aaroniker_me"><svg xmlns="http://www.w3.org/2000/svg" width="72" height="72" viewBox="0 0 72 72"><path d="M67.812 16.141a26.246 26.246 0 0 1-7.519 2.06 13.134 13.134 0 0 0 5.756-7.244 26.127 26.127 0 0 1-8.313 3.176A13.075 13.075 0 0 0 48.182 10c-7.229 0-13.092 5.861-13.092 13.093 0 1.026.118 2.021.338 2.981-10.885-.548-20.528-5.757-26.987-13.679a13.048 13.048 0 0 0-1.771 6.581c0 4.542 2.312 8.551 5.824 10.898a13.048 13.048 0 0 1-5.93-1.638c-.002.055-.002.11-.002.162 0 6.345 4.513 11.638 10.504 12.84a13.177 13.177 0 0 1-3.449.457c-.846 0-1.667-.078-2.465-.231 1.667 5.2 6.499 8.986 12.23 9.09a26.276 26.276 0 0 1-16.26 5.606A26.21 26.21 0 0 1 4 55.976a37.036 37.036 0 0 0 20.067 5.882c24.083 0 37.251-19.949 37.251-37.249 0-.566-.014-1.134-.039-1.694a26.597 26.597 0 0 0 6.533-6.774z"></path></svg></a>
.explore-menu {
border: none;
background: none;
outline: none;
color: #F9E7C5;
font-size: 16px;
line-height: 27px;
font-weight: 800;
font-family: 'Poppins', Arial;
display: block;
position: relative;
cursor: pointer;
width: 160px;
text-align: center;
border-radius: 26px;
padding: 0;
margin: 0;
backface-visibility: hidden;
-webkit-appearance: none;
-webkit-tap-highlight-color: transparent;
transition: transform var(--transform-duration, .4s);
will-change: transform;
transform-style: preserve-3d;
transform: perspective(480px) rotateX(calc(var(--rotate, 0deg) + var(--rx, 0deg))) rotateY(calc(0deg + var(--ry, 0deg))) translateZ(0);
&:hover {
--rotate: 18deg;
--easing: cubic-bezier(.8, .5, .2, 1.4);
--transform-duration: .15s;
--duration: .5s;
--top-y: -3px;
--top-z: 36px;
--pickle-x: 0;
--pickle-z: 5px;
--ketchup-y: -2px;
--ketchup-s: 1;
--ketchup-z: 28px;
--salad-s: 1;
--salad-z: 24px;
--cheese-y: 2px;
--cheese-s: 1;
--cheese-z: 16px;
--beef-y: 2px;
--beef-s: 1;
--beef-z: 4px;
--bottom-y: 2px;
--bottom-s: 1;
--pickle-y: 0;
&:after {
box-shadow: 36px 4px 0px rgba(0, 0, 0, 0.06), 16px 12px 0px rgba(0, 0, 0, 0.06), 20px 8px 0px rgba(0, 0, 0, 0.06);
}
}
&:active {
--duration: .25s;
--rotate: 16deg;
--pickle-x: 2px;
--top-y: -1px;
--top-z: 24px;
--ketchup-y: 0px;
--ketchup-s: .975;
--ketchup-z: 20px;
--salad-s: .975;
--salad-z: 16px;
--cheese-y: 1px;
--cheese-s: .975;
--cheese-z: 12px;
--beef-y: 1px;
--beef-s: .965;
--beef-z: 2px;
--bottom-y: 1px;
--bottom-s: .975;
&:after {
box-shadow: 24px 3px 0px rgba(0, 0, 0, 0.08), 10px 8px 0px rgba(0, 0, 0, 0.08), 16px 4px 0px rgba(0, 0, 0, 0.08);
}
}
.top {
position: relative;
z-index: 7;
padding: 12px 0;
background: radial-gradient(55% 165% at 50% 50%, #F0A151 0%, #D18334 100%);
box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.2), inset 0px -2.5px 0px rgba(0, 0, 0, 0.15);
border-radius: 26px;
text-shadow: 0 .5px 0 rgba(0, 0, 0, .15);
transform: translateY(var(--top-y, 0)) translateZ(var(--top-z, 1px));
transition: transform var(--duration, .3s) var(--easing, ease);
}
&:before,
&:after {
content: '';
display: block;
position: absolute;
}
&:before {
left: -2px;
top: 16px;
z-index: 3;
width: 28px;
height: 28px;
border-radius: 50%;
background: #A7BE5B;
box-shadow: inset 0px -2px 0px rgba(0, 0, 0, 0.25);
transform: translateX(var(--pickle-x, 8px)) translateZ(var(--pickle-z, 0));
transition: transform var(--duration, .3s) var(--easing, ease);
}
&:after {
position: absolute;
left: -2px;
top: 0;
width: 164px;
height: 53px;
background: #B1612E;
border-radius: 26px;
transform: translateY(var(--bottom-y, 0)) scale(var(--bottom-s, .8)) translateZ(0);
transition: transform var(--duration, .3s) var(--easing, ease), box-shadow var(--duration, .3s) var(--easing, ease);
}
.ketchup,
.salad,
.cheese {
position: absolute;
left: 0;
top: 0;
display: block;
width: 160px;
transition: transform var(--duration, .3s) var(--easing, ease);
}
.ketchup {
z-index: 6;
height: 54px;
fill: #D14253;
transform: translateY(var(--ketchup-y, 0)) scale(var(--ketchup-s, .9)) translateZ(var(--ketchup-z, 0));
}
.salad {
z-index: 5;
height: 52px;
fill: #5B9A70;
transform: scale(var(--salad-s, .8)) translateZ(var(--salad-z, 0));
}
.cheese {
z-index: 4;
height: 53px;
fill: #F89931;
transform: translateY(var(--cheese-y, 0)) scale(var(--cheese-s, .8)) translateZ(var(--cheese-z, 0));
}
.beef {
z-index: 2;
position: absolute;
left: -4px;
top: 0;
width: 168px;
height: 51px;
border-radius: 26px;
background: #6D392D;
box-shadow: inset 0px -2.5px 0px rgba(0, 0, 0, 0.25);
transform: translateY(var(--beef-y, 0)) scale(var(--beef-s, .75)) translateZ(var(--beef-z, 0));
transition: transform var(--duration, .3s) var(--easing, ease);
&:before,
&:after {
content: '';
display: block;
position: absolute;
}
&:before {
background: #000;
opacity: .25;
width: 10px;
height: 36px;
border-radius: 5px;
position: absolute;
left: 9px;
bottom: 8px;
box-shadow: 16px 3px 0 #000, 32px 3px 0 #000, 48px 3px 0 #000, 63px 3px 0 #000, 78px 3px 0 #000, 93px 3px 0 #000, 108px 3px 0 #000, 124px 3px 0 #000, 140px 0 0 #000;
}
&:after {
left: 97px;
top: 21px;
width: 28px;
height: 28px;
border-radius: 50%;
background: #A7BE5B;
box-shadow: inset 0px -2px 0px rgba(0, 0, 0, 0.25);
transform: translateY(var(--pickle-y, -6px)) translateZ(0);
transition: transform var(--duration, .3s) var(--easing, ease);
}
}
}
html {
box-sizing: border-box;
-webkit-font-smoothing: antialiased;
}
* {
box-sizing: inherit;
&:before,
&:after {
box-sizing: inherit;
}
}
// Center & dribbble
body {
min-height: 100vh;
display: flex;
font-family: 'Poppins', Arial;
justify-content: center;
align-items: center;
background: #1F1F24;
.dribbble {
position: fixed;
display: block;
right: 20px;
bottom: 20px;
img {
display: block;
height: 28px;
}
}
.twitter {
position: fixed;
display: block;
right: 64px;
bottom: 14px;
svg {
width: 32px;
height: 32px;
fill: #1da1f2;
}
}
}
document.querySelectorAll('.explore-menu').forEach(button => {
const bounding = button.getBoundingClientRect()
button.addEventListener('mousemove', e => {
let dy = (e.clientY - bounding.top - bounding.height / 2) / -1
let dx = (e.clientX - bounding.left - bounding.width / 2) / 10
dy = dy > 10 ? 10 : (dy < -10 ? -10 : dy);
dx = dx > 8 ? 8 : (dx < -8 ? -8 : dx);
button.style.setProperty('--rx', dy + 'deg');
button.style.setProperty('--ry', dx + 'deg');
});
button.addEventListener('mouseleave', e => {
button.style.setProperty('--rx', '0deg')
button.style.setProperty('--ry', '0deg')
});
});
Also see: Tab Triggers