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="example-cntr">
<h1>CSS <code>:hover</code> pseudo-class</h1>
<p>The <code>:hover</code> pseudo-class is used to style an element when the pointer is over it. It doesn’t have to be used with links, albeit is the most common use case.</p>
<p>This pseudo-class has to got be one of the most, if not THE most, versatile feature of CSS since so many great things can be accomplished with this pseudo-class.</p>
<!-- Fancy effect -->
<h3>Fancy effect</h3>
<section class="fancy-ctnr flex-ctnr">
<!-- "Guillotine" style -->
<a href="https://tympanus.net/Tutorials/ShapeHoverEffectSVG/index.html" target="_blank" title="Link opens in a new tab" data-path-hover="m 180,34.57627 -180,0 L 0,0 180,0 z">
<figure>
<img src="http://lorempixel.com/300/400/technics/2">
<svg viewBox="0 0 180 320" preserveAspectRatio="none"><path d="M 180,160 0,218 0,0 180,0 z"/></svg>
<figcaption>
<h2>Hover effect using SVG</h2>
<p>Guillotine shape</p>
<span class="button">View Article on Tympanus.net</span>
</figcaption>
</figure>
</a>
<!-- "Bubble" style -->
<a href="https://tympanus.net/Tutorials/ShapeHoverEffectSVG/index2.html" target="_blank" title="Link opens in a new tab" data-path-hover="m 0,0 0,47.7775 c 24.580441,3.12569 55.897012,-8.199417 90,-8.199417 34.10299,0 65.41956,11.325107 90,8.199417 L 180,0 z">
<figure>
<img src="http://lorempixel.com/300/400/technics/2">
<svg viewBox="0 0 180 320" preserveAspectRatio="none"><path d="m 0,0 0,171.14385 c 24.580441,15.47138 55.897012,24.75772 90,24.75772 34.10299,0 65.41956,-9.28634 90,-24.75772 L 180,0 0,0 z"/></svg>
<figcaption>
<h2>Hover effect using SVG</h2>
<p>Bubble shape</p>
<span class="button">View Article on Tympanus.net</span>
</figcaption>
</figure>
</a>
</section>
<!-- Navigation bars -->
<h3>Navigation bars</h3>
<section class="flex-ctnr nav-bars">
<ul class="hvr-underline-from-left">
<li><a href="#">1</a></li>
<li><a href="#">2</a></li>
<li><a href="#">3</a></li>
</ul>
<ul class="hvr-shutter-out-horizontal">
<li><a href="#">A</a></li>
<li><a href="#">B</a></li>
<li><a href="#">C</a></li>
</ul>
</section>
<!-- Images -->
<h3>Images</h3>
<section class="flex-ctnr images">
<a href="#" class="zoom"><img src="http://lorempixel.com/300/200/technics/2"></a>
<a href="#" class="sepia"><img src="http://lorempixel.com/300/200/fashion/7"></a>
</section>
</div>
/* Hover effects using SVG
Adapted from "Shape Hover Effect with SVG" - https://tympanus.net/codrops/2014/01/07/shape-hover-effect-with-svg/ */
/* Fancy effect */
.fancy-ctnr { margin: auto;
figure {
position: relative;
overflow: hidden;
margin: 5px;
background: #333;
img {
position: relative;
display: block;
width: 100%;
opacity: .7;
transition: opacity .3s;
}
}
figcaption {
position: absolute;
top: 0;
z-index: 11;
padding: 10px;
width: 100%;
height: 100%;
text-align: center;
h2 {
margin: 0;
color: black;
text-transform: uppercase;
letter-spacing: 1px;
font-weight: 300;
font-size: 130%;
transition: transform .3s;
transform: translateY(50px);
}
p {
color: rgba(black,.5);
font-size: 20px;
transform: translateY(50px);
}
}
figure .button {
width: 90%;
padding: 10px;
position: absolute;
border: none;
text-transform: uppercase;
letter-spacing: 1px;
font-weight: bold;
transition: opacity .3s, transform .3s;
}
figcaption, h2, p figure .button { backface-visibility: hidden; }
svg {
position: absolute;
top: -1px;
/* fixes rendering issue in FF */
z-index: 10;
width: 100%;
height: 100%;
path { fill: $y; }
}
a:hover {
figure img { opacity: 1; }
figcaption {
h2 { transform: translateY(0); }
p {
transform: translateY(0);
opacity: 0;
}
}
}
figure .button {
top: 50%;
left: 50%;
border: 3px solid #fff;
background: rgba(white, 0.7);
color: black;
opacity: 0;
transform: translateY(-50%) translateX(-50%) scale(0.25);
}
a:hover figure .button {
opacity: 1;
transform: translateY(-50%) translateX(-50%) scale(1);
}
}
/* Hover effects on Navigation bars
Adapted from Hover.css - https://ianlunn.github.io/Hover/ */
/* Underline From Left */
.hvr-underline-from-left {
a {
display: inline-block;
vertical-align: middle;
backface-visibility: hidden;
transform: translateZ(0);
-moz-osx-font-smoothing: grayscale;
position: relative;
overflow: hidden;
&:before {
content: "";
position: absolute;
z-index: -1;
left: 0;
right: 100%;
bottom: 0;
background: $y;
height: 4px;
transition-property: right;
transition-duration: .4s;
transition-timing-function: ease-out;
}
&:hover:before,
&:focus:before,
&:active:before { right: 0; }
}
}
/* Shutter Out Horizontal */
.hvr-shutter-out-horizontal {
a {
display: inline-block;
vertical-align: middle;
backface-visibility: hidden;
transform: translateZ(0);
-moz-osx-font-smoothing: grayscale;
position: relative;
background: #333;
transition-property: color;
transition-duration: 0.3s;
&:before {
content: "";
position: absolute;
z-index: -1;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: $r;
transform: scaleX(0);
transform-origin: 50%;
transition-property: transform;
transition-duration: .2s;
transition-timing-function: ease-out;
}
&:hover,
&:focus,
&:active {
color: white;
}
&:hover:before,
&:focus:before,
&:active:before {
transform: scaleX(1);
}
}
}
/* Hover effects on Images
Adapted from @nxworld's Pen: "demo:CSS image hover effects" https://codepen.io/nxworld/pen/ZYNOBZ */
/* Zoom In */
.zoom {
display: inline-block;
width: 300px; height: 200px;
overflow: hidden;
img {
transform: scale(1);
transition: .4s ease-in-out;
}
& img:hover {
transform: scale(1.3);
}
}
/* Sepia */
.sepia {
img {
display: block;
filter: sepia(1);
transition: .3s ease-in-out;
}
&:hover img {
filter: sepia(0);
}
}
//Styling stuff not needed for demo
body {
text-align: left;
line-height: 1.5;
}
a { text-decoration: none; }
h1 {
font-size: 22px;
text-transform: none;
border-bottom: #636363 1px dotted;
code {
display: inline-block;
margin-bottom: 10px;
color: $y;
background: none;
box-shadow: none;
}
}
h3 {
padding-bottom: 5px;
border-bottom: #444 1px solid;
font-family: Georgia;
font-style: italic;
}
code { font-size: 1em; }
ul:not(.normal) {
padding: 0;
list-style-type: none;
}
.example-cntr {
max-width: 800px;
margin: 0 auto 50px;
padding: 30px;
box-shadow: 0 1px 2px rgba(black,.3);
background: rgba(black,.15);
& > code {
display: block;
margin-bottom: 10px;
font-size: 22px;
color: $y;
background: none;
box-shadow: none;
}
}
.flex-ctnr {
display: flex;
flex-wrap: wrap;
justify-content: space-around;
}
//All navigation bars
.nav-bars {
ul {
display: flex;
justify-content: center;
flex-wrap: wrap;
width: 45%;
}
li {
flex-grow: 1;
margin: 1%;
text-align: center;
}
a {
display: block;
padding: 10px;
background: rgba(black,.1);
}
}
//This uses SnapSVG.js
(function() {
function init() {
var speed = 250,
easing = mina.easeinout;
[].slice.call(document.querySelectorAll('.fancy-ctnr > a')).forEach(function(el) {
var s = Snap(el.querySelector('svg')),
path = s.select('path'),
pathConfig = {
from: path.attr('d'),
to: el.getAttribute('data-path-hover')
};
el.addEventListener('mouseenter', function() {
path.animate({
'path': pathConfig.to
}, speed, easing);
});
el.addEventListener('mouseleave', function() {
path.animate({
'path': pathConfig.from
}, speed, easing);
});
});
}
init();
})();
Also see: Tab Triggers