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.
<h1>Simple Grid Hover Effect</h1>
<h4>Simulate a 3D card lift effect with > 50FPS</h4>
<p>Apply multiple box shadows to the grid-item :before pseudo element to simulate desried depth and light source. Then transition the opacity on :hover from 0 to 1. The lift is a translate transition.</p>
<p>Don't forget will-change for GPU the performance boost!</p>
<ul class="grid">
<li class="grid-item">1</li>
<li class="grid-item">2</li>
<li class="grid-item">3</li>
<li class="grid-item">4</li>
<li class="grid-item">5</li>
<li class="grid-item">6</li>
<li class="grid-item">7</li>
<li class="grid-item">8</li>
<li class="grid-item">9</li>
<li class="grid-item">10</li>
<li class="grid-item">11</li>
<li class="grid-item">12</li>
<li class="grid-item">13</li>
<li class="grid-item">14</li>
<li class="grid-item">15</li>
<li class="grid-item">16</li>
</ul>
// Variables =============================================================
$font-family: "Open Sans", Helvetica, Arial, sans-serif
// Mixins ================================================================
=absolute($top, $left, $right, $bottom)
position: absolute
top: $top
left: $left
right: $right
bottom: $bottom
=translate($x,$y)
-webkit-transform: translate($x,$y)
-webkit-transform: translate3d($x,$y,0)
-ms-transform: translate($x,$y)
-ms-transform: translate3d($x,$y,0)
transform: translate($x,$y)
transform: translate3d($x,$y,0)
// Colors ================================================================
// Boomer Colors
$boom: #330066
$boom-dk: darken($boom, 2%)
$boom-lt: #9966CC
// Font Colors
$font-dark: #333
// Base colors
$grey: #BDC4D0
$background-light: #F3F4F8
$background-dark: #2F3032
$border-light: darken($background-light, 2%)
$border-dark: darken($background-dark, 2%)
$primary-color: #004983
// Base ==================================================================
*:not(i)
font-family: $font-family
html
height: 100%
font-size: 16px
body
height: 100%
padding: 50px 0
background: $background-light
h1
margin: 0 0 0.25rem
font:
size: 2.5rem
weight: 300
text:
align: center
color: #333
h4
margin: 0 0 2rem
font:
size: 1.25rem
weight: 600
text:
align: center
color: $grey
p
max-width: 800px
margin: 0 auto 20px
font:
size: 0.875rem
weight: 400
text:
align: center
letter-spacing: 0.25px
color: #333
.grid
display: flex
flex:
direction: row
wrap: wrap
align:
content: flex-start
items: center
justify-content: center
max-width: 80%
height: 100%
margin: 0 auto
padding: 30px 0 0
list-style: none
.grid-item
display: flex
flex:
direction: column
grow: 0
shrink: 0
basis: 260px
align-items: center
justify-content: center
position: relative
height: 220px
margin-right: 10px
margin-bottom: 10px
font:
size: 3rem
weight: 600
color: #ecf0f7
background: white
box-shadow: inset 0px 0px 0px 1px $border-light
+translate(0,0)
transition: transform 0.14s ease-in, text-shadow 0.1s ease-in
will-change: transform
cursor: pointer
// Pseudo elements ------------------
&:before
content: ''
+absolute(0,0,0,0)
background: none
border-radius: 3px
box-shadow: 0 10px 24px 0px rgba(0,0,0,0.02), 0 8px 20px -2px rgba(0,0,0,0.06), 0 6px 10px -6px rgba(0,0,0,0.10)
transition: opacity 0.1s ease-in
will-change: opacity
opacity: 0
// CSS state ------------------------
&:hover
+translate(0,-4px)
&:before
opacity: 1
$(document).ready(function(){
});
Also see: Tab Triggers