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.
<!--
Title: Image hover effects
Description: Simple css image hover effects
Author: Pawel Galias
Author URI: http://pawgalias.eu
-->
<h1>Image hover effects</h1>
<div class="flexbox">
<div>
<h2>No effect</h2>
<div class="hover">
<img src="http://lorempixel.com/400/200/sports/" />
</div>
<div class="clearer"></div>
</div>
</div>
<div class="flexbox">
<div>
<h2>1# Zoom01 effect</h2>
<div class="hover zoom01">
<img src="http://lorempixel.com/400/200/abstract/" />
</div>
</div>
<div>
<h2>2# Zoom02 effect</h2>
<div class="hover zoom02">
<img src="http://lorempixel.com/400/200/abstract/" />
</div>
</div>
</div>
<div class="flexbox">
<div>
<h2>3# Slide right effect</h2>
<div class="hover slide01">
<img src="http://lorempixel.com/400/200/cats/" />
</div>
</div>
<div>
<h2>4# Slide down effect</h2>
<div class="hover slide02">
<img src="http://lorempixel.com/200/400/cats/" />
</div>
</div>
<div>
<h2>5# Slide up effect</h2>
<div class="hover slide03">
<img src="http://lorempixel.com/400/400/cats/" />
</div>
</div>
<div>
<h2>6# Slide left effect</h2>
<div class="hover slide04">
<img src="http://lorempixel.com/400/600/cats/" />
</div>
</div>
</div>
<div class="flexbox">
<div>
<h2>7# Shrink01 effect</h2>
<div class="hover shrink01">
<img src="http://lorempixel.com/800/600/food/" />
</div>
</div>
<div>
<h2>8# Shrink02 effect</h2>
<div class="hover shrink02">
<img src="http://lorempixel.com/600/400/food/" />
</div>
</div>
</div>
<div class="flexbox">
<div>
<h2>9# Rotate effect</h2>
<div class="hover rotate01">
<img src="http://lorempixel.com/400/400/transport/" />
</div>
</div>
<div>
<h2>10# Rotate+shrink effect</h2>
<div class="hover rotate02">
<img src="http://lorempixel.com/450/250/transport/" />
</div>
</div>
<div>
<h2>11# Morph effect</h2>
<div class="hover rotate03">
<img src="http://lorempixel.com/500/300/transport/" />
</div>
</div>
<div>
<h2>12# Tilt effect</h2>
<div class="hover rotate04">
<img src="http://lorempixel.com/450/300/transport/" />
</div>
</div>
<div>
<h2>13# Rotation + shrink effect</h2>
<div class="hover rotate05">
<img src="http://lorempixel.com/650/300/transport/" />
</div>
</div>
</div>
<div class="flexbox">
<div>
<h2>14# Blur effect</h2>
<div class="hover filter01">
<img src="http://lorempixel.com/400/200/city/" />
</div>
</div>
<div>
<h2>15# B&W effect</h2>
<div class="hover filter02">
<img src="http://lorempixel.com/500/300/city/" />
</div>
</div>
<div>
<h2>16# Brightness effect</h2>
<div class="hover filter03">
<img src="http://lorempixel.com/600/400/city/" />
</div>
</div>
<div>
<h2>17# Sepia effect</h2>
<div class="hover filter04">
<img src="http://lorempixel.com/450/300/city/" />
</div>
</div>
<div>
<h2>18# Saturate effect</h2>
<div class="hover filter05">
<img src="http://lorempixel.com/550/250/city/" />
</div>
</div>
<div>
<h2>19# Invert effect</h2>
<div class="hover filter06">
<img src="http://lorempixel.com/550/250/city/" />
</div>
</div>
<div>
<h2>20# B&W + Blur effect</h2>
<div class="hover filter07">
<img src="http://lorempixel.com/400/200/city/" />
</div>
</div>
</div>
<div class="flexbox">
<div>
<h2>21# Opacity01 effect</h2>
<div class="hover opacity01">
<img src="http://lorempixel.com/550/250/animals/" />
</div>
</div>
<div>
<h2>22# Opacity02 effect</h2>
<div class="hover opacity02">
<img src="http://lorempixel.com/400/200/animals/" />
</div>
</div>
</div>
<div class="flexbox">
<div>
<h2>23# Blink effect</h2>
<div class="hover animate01">
<img src="http://lorempixel.com/400/200/business/" />
</div>
</div>
<div>
<h2>24# Jump effect</h2>
<div class="hover animate02">
<img src="http://lorempixel.com/500/250/business/" />
</div>
</div>
<div>
<h2>25# Pulse effect</h2>
<div class="hover animate03">
<img src="http://lorempixel.com/500/250/abstract/" />
</div>
</div>
<div>
<h2>26# Wave effect</h2>
<div class="hover animate04">
<img src="http://lorempixel.com/300/300/cats" />
</div>
</div>
<div>
<h2>27# Round wave effect</h2>
<div class="hover animate05">
<img src="http://lorempixel.com/300/300/animals" />
</div>
</div>
</div>
/*
Title: Image hover effects
Description: Simple css image hover effects
Author: Pawel Galias
Author URI: http://pawgalias.eu
*/
h2 {
margin-top: 50px;
margin-bottom: 10px;
}
img {
margin-bottom: -4px;
}
.flexbox {
display: flex;
justify-content: space-around;
flex-wrap: wrap;
}
.hover {
border: 4px solid #000;
// size of image
width: 200px;
height: 200px;
overflow: hidden;
float: left;
-webkit-box-shadow: 0 0 20px 5px rgba(0,0,0,0.75);
-moz-box-shadow: 0 0 20px 5px rgba(0,0,0,0.75);
box-shadow: 0 0 20px 5px rgba(0,0,0,0.75);
}
// transition mixin
.transition(@transition: all .5s ease) {
-webkit-transition: @transition;
transition: @transition;
}
// tranform mixin
.transform(@transform) {
-webkit-transform: @transform;
-ms-transform: @transform;
transform: @transform;
}
.filter(@filter) {
-webkit-filter: @filter;
filter: @filter;
}
.animation(@animation) {
-webkit-animation: @animation;
animation: @animation;
}
// 1# effect
.zoom01 {
img {
.transition;
&:hover {
.transform(scale(1.3));
}
}
}
// 2# effect
.zoom02 {
img {
width: 200%;
height: auto;
.transition;
&:hover {
width: 300%;
}
}
}
// 3# effect
.slide01 {
img {
margin-left: 0;
.transition(margin .7s cubic-bezier(0, 1.65, 1, -.6));
&:hover {
margin-left: -200px;
}
}
}
// 4# effect
.slide02 {
img {
margin-top: 0;
.transition(margin .7s ease);
&:hover {
margin-top: -200px;
}
}
}
// 5# effect
.slide03 {
img {
margin-top: -200px;
.transition(margin .7s ease);
&:hover {
margin-top: 0;
}
}
}
// 6# effect
.slide04 {
img {
margin-left: -200px;
.transition(margin .7s ease);
&:hover {
margin-left: 0;
}
}
}
// 7# effect
.shrink01 {
img {
.transform(scale(1.5));
.transition;
&:hover {
.transform(scale(1));
}
}
}
// 8# effect
.shrink02 {
img {
width: 600px;
height: auto;
.transition;
&:hover {
width: 400px;
}
}
}
// 9# effect
.rotate01 {
position: relative;
img {
position: absolute;
top: -50%;
left: -50%;
.transform(rotate(15deg));
.transition;
&:hover {
.transform(rotate(0deg));
}
}
}
// 10# effect
.rotate02 {
img {
.transform(rotate(30deg) scale(2));
.transition;
&:hover {
.transform(rotate(0deg) scale(1));
}
}
}
// 11# effect
.rotate03 {
.transition;
&:hover {
border-radius: 50%;
}
}
// 12# effect
.rotate04 {
.transition;
&:hover {
.transform(rotate(10deg));
}
}
// 13# effect
.rotate05 {
.transition(all 1s ease);
&:hover {
.transform(rotate(720deg) scale(0.5));
}
}
// 14# effect
.filter01 {
img {
.transition;
.filter(blur(3px));
&:hover {
.filter(blur(0));
}
}
}
// 15# effect
.filter02 {
img {
.transition;
.filter(grayscale(100%));
&:hover {
.filter(grayscale(0));
}
}
}
// 16# effect
.filter03 {
img {
.transition;
.filter(brightness(3));
&:hover {
.filter(brightness(1));
}
}
}
// 17# effect
.filter04 {
img {
.transition;
.filter(sepia(100%));
&:hover {
.filter(sepia(0));
}
}
}
// 18# effect
.filter05 {
img {
.transition;
.filter(saturate(10));
&:hover {
.filter(saturate(0));
}
}
}
// 19# effect
.filter06 {
img {
.transition;
.filter(invert(1));
&:hover {
.filter(invert(0));
}
}
}
// 20# effect
.filter07 {
img {
.transition;
.filter(blur(10px) grayscale(1));
&:hover {
.filter(blur(0) grayscale(0));
}
}
}
// 21# effect
.opacity01 {
img {
.transition;
opacity: 1;
&:hover {
opacity: 0.4;
}
}
}
// 22# effect
.opacity02 {
background: #534f34;
img {
.transition;
opacity: 1;
&:hover {
opacity: 0.4;
}
}
}
// 23# effect
@keyframes blink {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
.animate01 {
img {
&:hover {
.animation(blink .5s);
}
}
}
// 24# effect
@keyframes jump {
0% {bottom: 0}
50% {bottom: 20px}
100% {bottom: 0}
}
.animate02 {
position: relative;
&:hover {
.animation(jump .5s);
}
}
// 25# effect
@keyframes pulse {
0% {.transform(scale(1.1));}
50% {.transform(scale(0.8));}
90% {.transform(scale(1));}
100% {.transform(scale(1));}
}
.animate03 {
&:hover {
.animation(pulse 1s infinite);
}
}
// 26# effect
@keyframes wave {
100% {left: -75%}
}
.animate04 {
position: relative;
&::after {
position: absolute;
width: 50%;
height: 100%;
top: 0;
left: 175%;
z-index: 999;
background: linear-gradient(to right, rgba(255,255,255,0) 0%, rgba(255,255,255,.3) 100%);
.transform(skewX(25deg));
display: block;
content: '';
}
&:hover::after {
.animation(wave .75s);
}
}
//27# effect
@keyframes round-wave {
0% {opacity:1;}
50% {opacity:1;}
100% {opacity:0;width:200%;height:200%;}
}
.animate05 {
position: relative;
&::after {
display: block;
content: '';
position: absolute;
top: 50%;
left: 50%;
.transform(translate(-50%,-50%));
background: rgba(255,255,255,.3);
width: 0;
height: 0;
border-radius: 50%;
}
&:hover::after {
.animation(round-wave .5s);
}
}
Also see: Tab Triggers