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 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.
<!--
/*
Inspired by article from CSS-tricks:
https://css-tricks.com/direction-aware-hover-effects/
*/
-->
<section class="c-gallery js-gallery">
<!--GALLERY ITEM-->
<div class="c-gallery__item" tabindex="0">
<!--HOVER PANELS-->
<div class="o-hover-panel__item o-hover-panel__item--top" aria-hidden="true"></div>
<div class="o-hover-panel__item o-hover-panel__item--right" aria-hidden="true"></div>
<div class="o-hover-panel__item o-hover-panel__item--bottom" aria-hidden="true"></div>
<div class="o-hover-panel__item o-hover-panel__item--left" aria-hidden="true"></div>
<!--IMAGE-->
<img src="https://farm5.staticflickr.com/4566/38440710721_5c510dfd77_o.jpg" class="c-gallery__image" width="350" height="350" alt="The-Beatles-Abbey-Road-album-covers-1000x1000" />
<!--REVEAL OVERLAYS-->
<div class="c-gallery__reveal-overlay c-gallery__reveal-overlay--swing-top">
<h3 class="c-gallery__reveal-title">Lorem ipsum</h3>
<p class="c-gallery__reveal-text">
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore eritatis et quasi.
</p>
</div>
<div class="c-gallery__reveal-overlay c-gallery__reveal-overlay--swing-right">
<h3 class="c-gallery__reveal-title">Lorem ipsum</h3>
<p class="c-gallery__reveal-text">
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore eritatis et quasi.
</p>
</div>
<div class="c-gallery__reveal-overlay c-gallery__reveal-overlay--swing-bottom">
<h3 class="c-gallery__reveal-title">Lorem ipsum</h3>
<p class="c-gallery__reveal-text">
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore eritatis et quasi.
</p>
</div>
<div class="c-gallery__reveal-overlay c-gallery__reveal-overlay--swing-left">
<h3 class="c-gallery__reveal-title" tabindex="0">Lorem ipsum</h3>
<p class="c-gallery__reveal-text" tabindex="0">
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore eritatis et quasi.
</p>
</div>
</div>
<!--GALLERY ITEM-->
<div class="c-gallery__item" tabindex="0">
<!--HOVER PANELS-->
<div class="o-hover-panel__item o-hover-panel__item--top" aria-hidden="true"></div>
<div class="o-hover-panel__item o-hover-panel__item--right" aria-hidden="true"></div>
<div class="o-hover-panel__item o-hover-panel__item--bottom" aria-hidden="true"></div>
<div class="o-hover-panel__item o-hover-panel__item--left" aria-hidden="true"></div>
<!--IMAGE-->
<img src="https://farm5.staticflickr.com/4566/38440710721_5c510dfd77_o.jpg" class="c-gallery__image" width="350" height="350" alt="The-Beatles-Abbey-Road-album-covers-1000x1000" />
<!--REVEAL OVERLAYS-->
<div class="c-gallery__reveal-overlay c-gallery__reveal-overlay--swing-top">
<h3 class="c-gallery__reveal-title">Lorem ipsum</h3>
<p class="c-gallery__reveal-text">
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore eritatis et quasi.
</p>
</div>
<div class="c-gallery__reveal-overlay c-gallery__reveal-overlay--swing-right">
<h3 class="c-gallery__reveal-title">Lorem ipsum</h3>
<p class="c-gallery__reveal-text">
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore eritatis et quasi.
</p>
</div>
<div class="c-gallery__reveal-overlay c-gallery__reveal-overlay--swing-bottom">
<h3 class="c-gallery__reveal-title">Lorem ipsum</h3>
<p class="c-gallery__reveal-text">
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore eritatis et quasi.
</p>
</div>
<div class="c-gallery__reveal-overlay c-gallery__reveal-overlay--swing-left">
<h3 class="c-gallery__reveal-title">Lorem ipsum</h3>
<p class="c-gallery__reveal-text">
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore eritatis et quasi.
</p>
</div>
</div>
<!--GALLERY ITEM-->
<div class="c-gallery__item" tabindex="0">
<!--HOVER PANELS-->
<div class="o-hover-panel__item o-hover-panel__item--top" aria-hidden="true"></div>
<div class="o-hover-panel__item o-hover-panel__item--right" aria-hidden="true"></div>
<div class="o-hover-panel__item o-hover-panel__item--bottom" aria-hidden="true"></div>
<div class="o-hover-panel__item o-hover-panel__item--left" aria-hidden="true"></div>
<!--IMAGE-->
<img src="https://farm5.staticflickr.com/4566/38440710721_5c510dfd77_o.jpg" class="c-gallery__image" width="350" height="350" alt="The-Beatles-Abbey-Road-album-covers-1000x1000" />
<!--REVEAL OVERLAYS-->
<div class="c-gallery__reveal-overlay c-gallery__reveal-overlay--swing-top">
<h3 class="c-gallery__reveal-title">Lorem ipsum</h3>
<p class="c-gallery__reveal-text">
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore eritatis et quasi.
</p>
</div>
<div class="c-gallery__reveal-overlay c-gallery__reveal-overlay--swing-right">
<h3 class="c-gallery__reveal-title">Lorem ipsum</h3>
<p class="c-gallery__reveal-text">
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore eritatis et quasi.
</p>
</div>
<div class="c-gallery__reveal-overlay c-gallery__reveal-overlay--swing-bottom">
<h3 class="c-gallery__reveal-title">Lorem ipsum</h3>
<p class="c-gallery__reveal-text">
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore eritatis et quasi.
</p>
</div>
<div class="c-gallery__reveal-overlay c-gallery__reveal-overlay--swing-left">
<h3 class="c-gallery__reveal-title">Lorem ipsum</h3>
<p class="c-gallery__reveal-text">
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore eritatis et quasi.
</p>
</div>
</div>
<!--GALLERY ITEM-->
<div class="c-gallery__item" tabindex="0">
<!--HOVER PANELS-->
<div class="o-hover-panel__item o-hover-panel__item--top" aria-hidden="true"></div>
<div class="o-hover-panel__item o-hover-panel__item--right" aria-hidden="true"></div>
<div class="o-hover-panel__item o-hover-panel__item--bottom" aria-hidden="true"></div>
<div class="o-hover-panel__item o-hover-panel__item--left" aria-hidden="true"></div>
<!--IMAGE-->
<img src="https://farm5.staticflickr.com/4566/38440710721_5c510dfd77_o.jpg" class="c-gallery__image" width="350" height="350" alt="The-Beatles-Abbey-Road-album-covers-1000x1000" />
<!--REVEAL OVERLAYS-->
<div class="c-gallery__reveal-overlay c-gallery__reveal-overlay--swing-top">
<h3 class="c-gallery__reveal-title">Lorem ipsum</h3>
<p class="c-gallery__reveal-text">
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore eritatis et quasi.
</p>
</div>
<div class="c-gallery__reveal-overlay c-gallery__reveal-overlay--swing-right">
<h3 class="c-gallery__reveal-title">Lorem ipsum</h3>
<p class="c-gallery__reveal-text">
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore eritatis et quasi.
</p>
</div>
<div class="c-gallery__reveal-overlay c-gallery__reveal-overlay--swing-bottom">
<h3 class="c-gallery__reveal-title">Lorem ipsum</h3>
<p class="c-gallery__reveal-text">
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore eritatis et quasi.
</p>
</div>
<div class="c-gallery__reveal-overlay c-gallery__reveal-overlay--swing-left">
<h3 class="c-gallery__reveal-title">Lorem ipsum</h3>
<p class="c-gallery__reveal-text">
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore eritatis et quasi.
</p>
</div>
</div>
<!--GALLERY ITEM-->
<div class="c-gallery__item" tabindex="0">
<!--HOVER PANELS-->
<div class="o-hover-panel__item o-hover-panel__item--top" aria-hidden="true"></div>
<div class="o-hover-panel__item o-hover-panel__item--right" aria-hidden="true"></div>
<div class="o-hover-panel__item o-hover-panel__item--bottom" aria-hidden="true"></div>
<div class="o-hover-panel__item o-hover-panel__item--left" aria-hidden="true"></div>
<!--IMAGE-->
<img src="https://farm5.staticflickr.com/4566/38440710721_5c510dfd77_o.jpg" class="c-gallery__image" width="350" height="350" alt="The-Beatles-Abbey-Road-album-covers-1000x1000" />
<!--REVEAL OVERLAYS-->
<div class="c-gallery__reveal-overlay c-gallery__reveal-overlay--swing-top">
<h3 class="c-gallery__reveal-title">Lorem ipsum</h3>
<p class="c-gallery__reveal-text">
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore eritatis et quasi.
</p>
</div>
<div class="c-gallery__reveal-overlay c-gallery__reveal-overlay--swing-right">
<h3 class="c-gallery__reveal-title">Lorem ipsum</h3>
<p class="c-gallery__reveal-text">
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore eritatis et quasi.
</p>
</div>
<div class="c-gallery__reveal-overlay c-gallery__reveal-overlay--swing-bottom">
<h3 class="c-gallery__reveal-title">Lorem ipsum</h3>
<p class="c-gallery__reveal-text">
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore eritatis et quasi.
</p>
</div>
<div class="c-gallery__reveal-overlay c-gallery__reveal-overlay--swing-left">
<h3 class="c-gallery__reveal-title">Lorem ipsum</h3>
<p class="c-gallery__reveal-text">
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore eritatis et quasi.
</p>
</div>
</div>
<!--GALLERY ITEM-->
<div class="c-gallery__item" tabindex="0">
<!--HOVER PANELS-->
<div class="o-hover-panel__item o-hover-panel__item--top" aria-hidden="true"></div>
<div class="o-hover-panel__item o-hover-panel__item--right" aria-hidden="true"></div>
<div class="o-hover-panel__item o-hover-panel__item--bottom" aria-hidden="true"></div>
<div class="o-hover-panel__item o-hover-panel__item--left" aria-hidden="true"></div>
<!--IMAGE-->
<img src="https://farm5.staticflickr.com/4566/38440710721_5c510dfd77_o.jpg" class="c-gallery__image" width="350" height="350" alt="The-Beatles-Abbey-Road-album-covers-1000x1000" />
<!--REVEAL OVERLAYS-->
<div class="c-gallery__reveal-overlay c-gallery__reveal-overlay--swing-top">
<h3 class="c-gallery__reveal-title">Lorem ipsum</h3>
<p class="c-gallery__reveal-text">
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore eritatis et quasi.
</p>
</div>
<div class="c-gallery__reveal-overlay c-gallery__reveal-overlay--swing-right">
<h3 class="c-gallery__reveal-title">Lorem ipsum</h3>
<p class="c-gallery__reveal-text">
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore eritatis et quasi.
</p>
</div>
<div class="c-gallery__reveal-overlay c-gallery__reveal-overlay--swing-bottom">
<h3 class="c-gallery__reveal-title">Lorem ipsum</h3>
<p class="c-gallery__reveal-text">
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore eritatis et quasi.
</p>
</div>
<div class="c-gallery__reveal-overlay c-gallery__reveal-overlay--swing-left">
<h3 class="c-gallery__reveal-title">Lorem ipsum</h3>
<p class="c-gallery__reveal-text">
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore eritatis et quasi.
</p>
</div>
</div>
<!--GALLERY ITEM-->
<div class="c-gallery__item" tabindex="0">
<!--HOVER PANELS-->
<div class="o-hover-panel__item o-hover-panel__item--top" aria-hidden="true"></div>
<div class="o-hover-panel__item o-hover-panel__item--right" aria-hidden="true"></div>
<div class="o-hover-panel__item o-hover-panel__item--bottom" aria-hidden="true"></div>
<div class="o-hover-panel__item o-hover-panel__item--left" aria-hidden="true"></div>
<!--IMAGE-->
<img src="https://farm5.staticflickr.com/4566/38440710721_5c510dfd77_o.jpg" class="c-gallery__image" width="350" height="350" alt="The-Beatles-Abbey-Road-album-covers-1000x1000" />
<!--REVEAL OVERLAYS-->
<div class="c-gallery__reveal-overlay c-gallery__reveal-overlay--swing-top">
<h3 class="c-gallery__reveal-title">Lorem ipsum</h3>
<p class="c-gallery__reveal-text">
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore eritatis et quasi.
</p>
</div>
<div class="c-gallery__reveal-overlay c-gallery__reveal-overlay--swing-right">
<h3 class="c-gallery__reveal-title">Lorem ipsum</h3>
<p class="c-gallery__reveal-text">
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore eritatis et quasi.
</p>
</div>
<div class="c-gallery__reveal-overlay c-gallery__reveal-overlay--swing-bottom">
<h3 class="c-gallery__reveal-title">Lorem ipsum</h3>
<p class="c-gallery__reveal-text">
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore eritatis et quasi.
</p>
</div>
<div class="c-gallery__reveal-overlay c-gallery__reveal-overlay--swing-left">
<h3 class="c-gallery__reveal-title">Lorem ipsum</h3>
<p class="c-gallery__reveal-text">
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore eritatis et quasi.
</p>
</div>
</div>
<!--GALLERY ITEM-->
<div class="c-gallery__item" tabindex="0">
<!--HOVER PANELS-->
<div class="o-hover-panel__item o-hover-panel__item--top" aria-hidden="true"></div>
<div class="o-hover-panel__item o-hover-panel__item--right" aria-hidden="true"></div>
<div class="o-hover-panel__item o-hover-panel__item--bottom" aria-hidden="true"></div>
<div class="o-hover-panel__item o-hover-panel__item--left" aria-hidden="true"></div>
<!--IMAGE-->
<img src="https://farm5.staticflickr.com/4566/38440710721_5c510dfd77_o.jpg" class="c-gallery__image" width="350" height="350" alt="The-Beatles-Abbey-Road-album-covers-1000x1000" />
<!--REVEAL OVERLAYS-->
<div class="c-gallery__reveal-overlay c-gallery__reveal-overlay--swing-top">
<h3 class="c-gallery__reveal-title">Lorem ipsum</h3>
<p class="c-gallery__reveal-text">
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore eritatis et quasi.
</p>
</div>
<div class="c-gallery__reveal-overlay c-gallery__reveal-overlay--swing-right">
<h3 class="c-gallery__reveal-title">Lorem ipsum</h3>
<p class="c-gallery__reveal-text">
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore eritatis et quasi.
</p>
</div>
<div class="c-gallery__reveal-overlay c-gallery__reveal-overlay--swing-bottom">
<h3 class="c-gallery__reveal-title">Lorem ipsum</h3>
<p class="c-gallery__reveal-text">
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore eritatis et quasi.
</p>
</div>
<div class="c-gallery__reveal-overlay c-gallery__reveal-overlay--swing-left">
<h3 class="c-gallery__reveal-title">Lorem ipsum</h3>
<p class="c-gallery__reveal-text">
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore eritatis et quasi.
</p>
</div>
</div>
<!--GALLERY ITEM-->
<div class="c-gallery__item" tabindex="0">
<!--HOVER PANELS-->
<div class="o-hover-panel__item o-hover-panel__item--top" aria-hidden="true"></div>
<div class="o-hover-panel__item o-hover-panel__item--right" aria-hidden="true"></div>
<div class="o-hover-panel__item o-hover-panel__item--bottom" aria-hidden="true"></div>
<div class="o-hover-panel__item o-hover-panel__item--left" aria-hidden="true"></div>
<!--IMAGE-->
<img src="https://farm5.staticflickr.com/4566/38440710721_5c510dfd77_o.jpg" class="c-gallery__image" width="350" height="350" alt="The-Beatles-Abbey-Road-album-covers-1000x1000" />
<!--REVEAL OVERLAYS-->
<div class="c-gallery__reveal-overlay c-gallery__reveal-overlay--swing-top">
<h3 class="c-gallery__reveal-title">Lorem ipsum</h3>
<p class="c-gallery__reveal-text">
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore eritatis et quasi.
</p>
</div>
<div class="c-gallery__reveal-overlay c-gallery__reveal-overlay--swing-right">
<h3 class="c-gallery__reveal-title">Lorem ipsum</h3>
<p class="c-gallery__reveal-text">
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore eritatis et quasi.
</p>
</div>
<div class="c-gallery__reveal-overlay c-gallery__reveal-overlay--swing-bottom">
<h3 class="c-gallery__reveal-title">Lorem ipsum</h3>
<p class="c-gallery__reveal-text">
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore eritatis et quasi.
</p>
</div>
<div class="c-gallery__reveal-overlay c-gallery__reveal-overlay--swing-left">
<h3 class="c-gallery__reveal-title">Lorem ipsum</h3>
<p class="c-gallery__reveal-text">
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore eritatis et quasi.
</p>
</div>
</div>
</section>
HTML {
/*using system font-stack*/
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
font-size: 115%; /*~18px*/
/*using fluid typography (https://goo.gl/o9sRyq)*/
font-size: calc(16px + (20 - 16) * (100vw - 300px) / (1300 - 300) );
line-height: 1.5;
box-sizing: border-box;
}
BODY {
color: #3a3d40;
margin: 0;
}
*, *::before, *::after {
box-sizing: inherit;
color: inherit;
}
/*Actual Style*/
/*==================
Gallery
====================*/
.c-gallery {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(17.5rem, 1fr));
grid-row-gap: 0.5rem;
justify-items: center;
padding: 1rem;
border: 1px solid;
}
/*==================
Gallery Item
====================*/
.c-gallery__item {
position: relative;
width: 17.5rem; /*350px*/
height: 17.5rem;/*350px*/
overflow: hidden;
-webkit-perspective: 1200px;
perspective: 1200px;
/* border: 5px solid green; */
}
.c-gallery__item:focus {
border: 1px solid rgb(166, 200, 255);
}
.c-gallery__item:focus-within {
border: 1px solid rgb(166, 200, 255);
}
/*==================
Hover Panel Item
====================*/
.o-hover-panel__item {
position: absolute;
width: 70.71%;
height: 70.71%;
transform: rotate(45deg);
z-index: 1;
/* border: 3px dotted green; */
}
.o-hover-panel__item:hover {
left: 0; top:0;
width: 100%; height: 100%;
transform: none;
z-index: 2;
}
/*Hover Panel TOP*/
/*---------------*/
.o-hover-panel__item--top {
left: 15%; top: -35%;
border-color: blue;
}
/*Hover Panel RIGHT*/
/*---------------*/
.o-hover-panel__item--right {
right: -35%; top: 15%;
border-color: yellow;
}
/*Hover Panel BOTTOM*/
/*---------------*/
.o-hover-panel__item--bottom {
left: 15%; bottom: -35%;
border-color: cyan;
}
/*Hover Panel LEFT*/
/*---------------*/
.o-hover-panel__item--left {
left: -35%; top: 15%;
border-color: red;
}
/*==================
Gallery Image
====================*/
.c-gallery__image {
width: 100%;
height: 100%;
}
/*==================
Reveal Overlay
====================*/
.c-gallery__reveal-overlay {
position: absolute;
left: 0; top: 0;
width: 100%; height: 100%;
padding: 1rem;
background: rgba(0, 0, 0, .8);
color: #f1f1f1;
/* border: 1px groove; */
transition: transform .3s ease-out;
}
.o-hover-panel__item:hover ~ .c-gallery__reveal-overlay,
.c-gallery__reveal-overlay:hover {
z-index: 3;
}
/*==================
Revealing Effects
====================*/
/*Default TOP Revealing*/
/*---------------------*/
.c-gallery__reveal-overlay--top {
transform: translateY(-100%);
}
.o-hover-panel__item--top:hover ~ .c-gallery__reveal-overlay--top,
.c-gallery__reveal-overlay--top:hover {
transform: translateY(0%);
}
/*Swing TOP Revealing*/
/*---------------------*/
.c-gallery__reveal-overlay--swing-top {
perspective-origin: center top;
transform-origin: 50% 0;
transform: rotate3d(-1, 0, 0, 120deg);
}
.o-hover-panel__item--top:hover ~ .c-gallery__reveal-overlay--swing-top,
.c-gallery__reveal-overlay--swing-top:hover {
transform: rotate3d(1, 0, 0, 0deg);
}
/*Default RIGHT Revealing*/
/*---------------------*/
.c-gallery__reveal-overlay--right {
transform: translateX(100%);
}
.o-hover-panel__item--right:hover ~ .c-gallery__reveal-overlay--right,
.c-gallery__reveal-overlay--right:hover {
transform: translateX(0%);
}
/*Swing RIGHT Revealing*/
/*---------------------*/
.c-gallery__reveal-overlay--swing-right {
perspective-origin: center top;
transform-origin: 100% 50%;
transform: rotate3d(0, 1, 0, -120deg);
}
.o-hover-panel__item--right:hover ~ .c-gallery__reveal-overlay--swing-right,
.c-gallery__reveal-overlay--swing-right:hover {
transform: rotate3d(0, -1, 0, 0deg);
}
/*Default BOTTOM Revealing*/
/*---------------------*/
.c-gallery__reveal-overlay--bottom {
transform: translateY(100%);
}
.o-hover-panel__item--bottom:hover ~ .c-gallery__reveal-overlay--bottom,
.c-gallery__reveal-overlay--bottom:hover {
transform: translateY(0%);
}
/*Swing BOTTOM Revealing*/
/*---------------------*/
.c-gallery__reveal-overlay--swing-bottom {
perspective-origin: center top;
transform-origin: 50% 100%;
transform: rotate3d(-1, 0, 0, -120deg);
}
.o-hover-panel__item--bottom:hover ~ .c-gallery__reveal-overlay--swing-bottom,
.c-gallery__reveal-overlay--swing-bottom:hover {
transform: rotate3d(1, 0, 0, 0deg);
}
/*Default LEFT Revealing*/
/*---------------------*/
.c-gallery__reveal-overlay--left {
transform: translateX(-100%);
}
.o-hover-panel__item--left:hover ~ .c-gallery__reveal-overlay--left,
.c-gallery__reveal-overlay--left:hover {
transform: translateX(0%);
}
/*
NOTE: this will be applied only when parent (e.g. body/html)
has class that indicates that user is currently using keyboard
to tab over items without using mouse
*/
.is-using-keyboard .c-gallery__item:focus:not(:hover) .c-gallery__reveal-overlay--left {
transform: translateX(0%);
}
/*
NOTE: here we are using new feature that has limited support
as of 02.2018 this pseudo class is supported in
Chrome Edge Firefox IE Opera Safari
60 No 52 No 47 10.1
more info about :focus-within can be found in MDN:
https://developer.mozilla.org/en-US/docs/Web/CSS/:focus-within
In a nutshell, it represents an element that matched by the :focus pseudo-class
or has a descendant that is matched by :focus.
*/
.is-using-keyboard .c-gallery__item:focus-within:not(:hover) .c-gallery__reveal-overlay--left {
transform: translateX(0%);
}
/*Rotate LEFT Revealing*/
/*---------------------*/
.c-gallery__reveal-overlay--rotate-left {
transform-origin: 0 0;
transform: rotate(90deg);
}
.o-hover-panel__item--left:hover ~ .c-gallery__reveal-overlay--rotate-left,
.c-gallery__reveal-overlay--rotate-left:hover {
transform: rotate(0deg);
}
/*
NOTE: this will be applied only when parent (e.g. body/html)
has class that indicates that user is currently using keyboard
to tab over items without using mouse
*/
.is-using-keyboard .c-gallery__item:focus:not(:hover) .c-gallery__reveal-overlay--rotate-left {
transform: translateX(0%);
}
/*
NOTE: here we are using new feature that has limited support
as of 02.2018 this pseudo class is supported in
Chrome Edge Firefox IE Opera Safari
60 No 52 No 47 10.1
more info about :focus-within can be found in MDN:
https://developer.mozilla.org/en-US/docs/Web/CSS/:focus-within
In a nutshell, it represents an element that matched by the :focus pseudo-class
or has a descendant that is matched by :focus.
*/
.is-using-keyboard .c-gallery__item:focus-within:not(:hover) .c-gallery__reveal-overlay--rotate-left {
transform: translateX(0%);
}
/*Swing LEFT Revealing*/
/*---------------------*/
.c-gallery__reveal-overlay--swing-left {
perspective-origin: center top;
transform-origin: 0% 50%;
transform: rotate3d(0, -1, 0, -120deg);
}
.o-hover-panel__item--left:hover ~ .c-gallery__reveal-overlay--swing-left,
.c-gallery__reveal-overlay--swing-left:hover {
transform: rotate3d(0, 1, 0, 0deg);
}
/*
NOTE: this will be applied only when parent (e.g. body/html)
has class that indicates that user is currently using keyboard
to tab over items without using mouse
*/
.is-using-keyboard .c-gallery__item:focus:not(:hover) .c-gallery__reveal-overlay--swing-left {
transform: translateX(0%);
}
/*
NOTE: here we are using new feature that has limited support
as of 02.2018 this pseudo class is supported in
Chrome Edge Firefox IE Opera Safari
60 No 52 No 47 10.1
more info about :focus-within can be found in MDN:
https://developer.mozilla.org/en-US/docs/Web/CSS/:focus-within
In a nutshell, it represents an element that matched by the :focus pseudo-class
or has a descendant that is matched by :focus.
*/
.is-using-keyboard .c-gallery__item:focus-within:not(:hover) .c-gallery__reveal-overlay--swing-left {
transform: translateX(0%);
}
/*==================
Reveal Title
====================*/
.c-gallery__reveal-title {
}
/*==================
Reveal Text
====================*/
.c-gallery__reveal-text {
}
.c-gallery__reveal-title:focus,
.c-gallery__reveal-text:focus {
outline: 1px solid rgb(166, 200, 255);
}
/*=== @MEDIA ===*/
@media (pointer:fine) {
/*==================
Gallery Item
====================*/
/* .c-gallery__item:focus:not(:hover) {
border: 1px solid blue;
} */
/*==================
Revealing Effects
====================*/
/*Swing LEFT Revealing*/
/*---------------------*/
/* .c-gallery__item:focus:not(:hover) .c-gallery__reveal-overlay--swing-left {
transform: translateX(0%);
}
.c-gallery__item:focus:not(:hover) .c-gallery__reveal-overlay--rotate-left {
transform: translateX(0%);
}
.c-gallery__item:focus:not(:hover) .c-gallery__reveal-overlay--left {
transform: translateX(0%);
} */
}
/**
* Script for keyboard use detection,
* when user TABs over gallery, using Tab key, we detect it and add specific class to the body/html tag
* in order to denote it and use this in CSS,
* once user moves mouse we remove this class
*/
;(function () {
"use strict";
const galleries = document.querySelectorAll(".js-gallery");
const KEY = {
"TAB": ["Tab", 9] // we cover 2 properties here (e.key & e.keyCode) for better compatibility
};
const KEYBOARD_USE_DETECTION_CLASS = "is-using-keyboard";
/*============================
ADDING EVENT LISTENERS
==============================*/
galleries.forEach(function (gallery) {
gallery.addEventListener("keyup", galleryOnKeyUp);
});
document.addEventListener("mousemove", actThenThrottleEvents(galleryOnMouseMove, 200));
/*============================
EVENT LISTENERS
==============================*/
/**
* Fires when user is trying to use keyboard on the image gallery
*/
function galleryOnKeyUp (e) {
const pressedKey = e.key || e.keyCode;
debugger;
if(isValidKey(KEY.TAB, pressedKey)) {
// set class on the body in order to denote that user is, currently, using keyboard
document.body.classList.add(KEYBOARD_USE_DETECTION_CLASS);
}
};
/**
* Fires when mouse is mover, i.e. user doesn't use keyboard anymore
*/
function galleryOnMouseMove (e) {
/// user using mouse, so remove this class from the body
document.body.classList.remove(KEYBOARD_USE_DETECTION_CLASS);
};
/*======================
Utility Functions
======================*/
/*
* Determines whether provided key code is located into key codes array.
* @param {Array} keyCodes - Array of predefined, valid key codes to check against.
* @param {String/Number} keyCode - Provided key code to check.
* @return {Boolean} TRUE if provided key code has been found, otherwise returns FALSE
*/
function isValidKey(keyCodes, keyCode) {
let result = false;
result = keyCodes.some(function(v) {
return v === keyCode;
});
return result;
};
/**
* Generates an event listener wrapper function
* that will prevent the main listener from running
* if it has previously run within the given delay (in ms).
*/
function actThenThrottleEvents(listener, delay) {
var timeout;
return function(e) {
if (!timeout) { // no timer running
listener(e); // run the function
timeout = setTimeout( function() { timeout = null },
delay); // start a timer that turns itself off when it's done
}
//else, do nothing (we're in a throttling stage)
}
};
})();
Also see: Tab Triggers