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 URL's added here will be added as <link>
s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.
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.
If the stylesheet 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 CSS 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.
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 Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
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.
<nav id=menu_container class=menu_container>
<ul id=menu class=menu>
<li><a class=menu_lnk-1 href="">Articles</a></li>
<li><a class=menu_lnk-2 href="">Tools</a></li>
<li><a class=menu_lnk-3 href="">CodePens</a></li>
<li><a class=menu_lnk-4 href="">Portfolio</a></li>
</ul>
</nav>
<section style="margin:1rem">
<p>Removed the initial transform transition and replaced with a filter transition.<br>Much more consistant cross-browser.<br>Border looks better in black and thicker now too.</p>
</section>
<section>
<label>Border width: <input id="rangeBorder" type="range" min="0" max="5" value="1"/></label>
<!-- <label>Blur width: <input id="rangeBlur" type="range" min="0" max="5" value="2"/></label> -->
<script>
/* Just for the sliders */
var rangeBorder = document.getElementById("rangeBorder");
rangeBorder.addEventListener("change", function () {
document.getElementById("menu").className = "menu border" + this.value;
}, false);
var rangeBlur = document.getElementById("rangeBlur");
rangeBlur.addEventListener("change", function () {
document.getElementById("menu_container").className = "menu_container blur" + this.value;
}, false);
</script>
</section>
<!--
<footer>
<div class="menu_container-footer">
<ul class="menu">
<li><a class=menu_lnk-1 href="">Contact</a></li>
<li><a class=menu_lnk-3 href="">Site-map</a></li>
<li><a class=menu_lnk-4 href="">Accessibility</a></li>
<li><a class=menu_lnk-2 href="">Privacy</a></li>
<li><a class=menu_lnk-1 href="">T&Cs</a></li>
</ul>
</div>
</footer>
-->
body {
max-width: none;
padding: 0;
}
*, *::after, *::before {
-moz-box-sizing: inherit;
-webkit-box-sizing: inherit;
box-sizing: inherit;
}
footer {
width: 100%;
position:fixed;
bottom: 0;
}
[class^="menu_container"] {
margin: 0;
padding: 0 2.618rem;
background-color: #4B3D5A;
}
.menu {
display: flex;
max-width: 34rem;
flex-wrap: wrap;
align-items: center;
justify-content: flex-start;
list-style: none;
margin: 0;
padding: 0;
}
.menu li {
margin: .618rem;
flex: 1 1 0;
text-align: center;
}
[class*="menu_lnk"],
[class*="menu2_lnk"] {
padding: .618rem;
color: #fff;
z-index: 5;
text-decoration: none;
position: relative;
display: block;
background-color: #4B3D5A;
}
[class*="menu2_lnk"]:focus,
[class*="menu_lnk"]:focus {
outline: 1px solid transparent;
}
[class*="menu2_lnk"]::before {
/* background-color: black; */
background-image: url(#bg_goo);
background-size: contain;
content: " ";
display: block;
position:absolute;
top:0;
left:0;
width: 100%;
height: 100%;
z-index: 5;
}
/* Menu link ::before has the wobble */
[class*="menu_lnk"]::before {
background-color: black;
background-color: #0e001d;
content: "";
display: block;
position:absolute;
top:0;
left:0;
width: 100%;
height: 100%;
z-index: -1;
/* This was ignored by Chrome
transition: transform .3s ease-out, opacity .3s ease-out;
transform: scale(0);
opacity: 0; */
/* Testing filter transition instead, not quite the same though */
transition: -webkit-filter .3s ease-in, filter .3s ease-in;
-webkit-filter: blur(2px) opacity(0%);
filter: blur(2px) opacity(0%);
border: 3px solid #000;
margin-top: -3px;
animation: menu-hover-off .5s ease-out forwards;
}
[class*="menu_lnk"]:hover::before,
[class*="menu_lnk"]:focus::before {
/* Ignored by Chrome
transform: scale(1.1, 1.2);
opacity: 1;*/
-webkit-filter: blur(2px) opacity(100%);
filter: blur(2px) opacity(100%);
animation: menu-hover-on 1s ease-in .25s infinite;
}
/* variance */
.menu_lnk-1::before {
border-radius: .5rem 100%;
}
.menu_lnk-2::before {
border-radius: 1rem 50%;
}
.menu_lnk-3::before {
border-radius: .5rem 2rem .5rem 100%;
}
.menu_lnk-4::before {
border-radius: 1rem 100% 100% 100% ;
}
/* Rectangular objects */
@keyframes menu-hover-on {
0% {transform: rotate(0deg); border-radius: .5rem 100%;}
10% {transform: rotate(-4deg); border-radius: 25% 100% 25% 50%}
20% {transform: rotate(0deg); border-radius: .5rem 100%;}
30% {transform: rotate(-4deg); border-radius: 25% 50% 25% 100%;}
40% {transform: rotate(0deg); border-radius: .5rem 100%;}
50% {transform: rotate(0deg); border-radius: 100%;}
60% {transform: rotate(0deg); border-radius: .5rem 100%;}
70% {transform: rotate(4deg); border-radius: 100% 25% 50% 25%;}
80% {transform: rotate(0deg); border-radius: .5rem 100%;}
90% {transform: rotate(4deg); border-radius: 50% 25% 100% 25%}
100% {transform: rotate(0deg); border-radius: .5rem 100%;}
}
@keyframes menu-hover-off {
0% {transform: scale(1); opacity: 1}
100% {transform: scale(0); opacity: 0}
}
/* Sliders */
section {
margin-top: 3rem;
}
label {
display: block;
margin: 1rem;
}
[type="range"] {
vertical-align:bottom
}
/* Playing with border values */
.border0 ::before {
border-width: 0px;
}
.border1 ::before {
margin-top: -1px;
border-width: 1px;
}
.border2 ::before {
margin-top: -2px;
border-width: 2px;
}
.border3 ::before {
margin-top: -3px;
border-width: 3px;
}
.border4 ::before {
margin-top: -4px;
border-width: 4px;
}
.border5 ::before {
margin-top: -5px;
border-width: 5px;
}
/* Playing with blur values */
.blur0 ::before {
-webkit-filter: blur(0);
filter: blur(0);
}
.blur1 ::before {
-webkit-filter: blur(1px);
filter: blur(1px);
}
.blur2 ::before {
-webkit-filter: blur(2px);
filter: blur(2px);
}
.blur3 ::before {
-webkit-filter: blur(3px);
filter: blur(3px);
}
.blur4 ::before {
-webkit-filter: blur(4px);
filter: blur(4px);
}
.blur5 ::before {
-webkit-filter: blur(5px);
filter: blur(5px);
}
/* This only works on round objects */
@keyframes menu-hover-on-i-ROUND {
0% {transform: scale(1) rotate(0deg); border-radius: 50%}
10% {transform: scale(1) rotate(30deg); border-radius: 20% 50% 30% 50%}
20% {transform: scale(1) rotate(0deg); border-radius: 50%}
30% {transform: scale(1) rotate(-30deg); border-radius: 20% 50% 30% 50%}
40% {transform: scale(1) rotate(0deg); border-radius: 50%}
50% {transform: scale(1) rotate(30deg); border-radius: 50% 20% 50% 30%}
60% {transform: scale(1) rotate(0deg); border-radius: 50%}
70% {transform: scale(1) rotate(-30deg); border-radius: 50% 30% 50% 20%}
80% {transform: scale(1) rotate(0deg); border-radius: 50%}
90% {transform: scale(1) rotate(30deg); border-radius: 20% 20% 30% 30%}
100% {transform: scale(1) rotate(0deg); border-radius: 50%}
}
Also see: Tab Triggers