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.
<!--images from http://haryarti.deviantart.com/gallery/-->
<div class="container">
<ul class="gallery">
<li>
<div class="flip">
<div class="front-side"></div>
<div class="back-side">
<a href="#">
<div class="content">
<div class="loader"></div>
<div class="text">
<h3>LINA</h3>
<p>The sibling rivalries between Lina the Slayer, and her younger sister Rylai, the Crystal Maiden, were the stuff of legend in the temperate region where they spent their quarrelsome childhoods together. Lina always had the advantage, however, for while Crystal was guileless and naive, Lina's fiery ardor was tempered by cleverness and conniving. The exasperated parents of these incompatible offspring went through half a dozen homesteads, losing one to fire, the next to ice, before they realized life would be simpler if the children were separated.</p>
</div>
</div>
</a>
</div>
</div>
</li>
<li>
<div class="flip">
<div class="front-side"></div>
<div class="back-side">
<a href="#">
<div class="content">
<div class="loader"></div>
<div class="text">
<h3>CRYSTAL MAIDEN</h3>
<p>Born in a temperate realm, raised with her fiery older sister Lina, Rylai the Crystal Maiden soon found that her innate elemental affinity to ice created trouble for all those around her. Wellsprings and mountain rivers froze in moments if she stopped to rest nearby; ripening crops were bitten by frost, and fruiting orchards turned to mazes of ice and came crashing down, spoiled. When their exasperated parents packed Lina off to the equator, Rylai found herself banished to the cold northern realm of Icewrack, where she was taken in by an Ice Wizard who had carved himself a hermitage at the crown of the Blueheart Glacier.</p>
</div>
</div>
</a>
</div>
</div>
</li>
<li>
<div class="flip">
<div class="front-side"></div>
<div class="back-side">
<a href="#">
<div class="content">
<div class="loader"></div>
<div class="text">
<h3>DROW RANGER</h3>
<p>Drow Ranger's given name is Traxex--a name well suited to the short, trollish, rather repulsive Drow people. But Traxex herself is not a Drow. Her parents were travelers in a caravan set upon by bandits, whose noisy slaughter of innocents roused the ire of the quiet Drow people. After the battle settled, the Drow discovered a small girl-child hiding in the ruined wagons, and agreed she could not be abandoned. Even as child, Traxex showed herself naturally adept at the arts they prized: Stealth, silence, subtlety. In spirit, if not in physique, she might have been a Drow changeling, returned to her proper home. But as she grew, she towered above her family and came to think of herself as ugly.</p>
</div>
</div>
</a>
</div>
</div>
</li>
<li>
<div class="flip">
<div class="front-side"></div>
<div class="back-side">
<a href="#">
<div class="content">
<div class="loader"></div>
<div class="text">
<h3>WINDRANGER</h3>
<p>The western forests guard their secrets well. One of these is Lyralei, master archer of the wood, and favored godchild of the wind. Known now as Windranger, Lyralei's family was killed in a storm on the night of her birth--their house blown down by the gale, contents scattered to the winds. Only the newborn survived among the debris field of death and destruction. In the quiet after the storm, the wind itself took notice of the lucky infant crying in the grass. The wind pitied the child and so lifted her into the sky and deposited her on a doorstep in a neighboring village.</p>
</div>
</div>
</a>
</div>
</div>
</li>
<li>
<div class="flip">
<div class="front-side"></div>
<div class="back-side">
<a href="#">
<div class="content">
<div class="loader"></div>
<div class="text">
<h3>DEATH PROPHET</h3>
<p>Krobelus was a Death Prophet--which is one way of saying she told fortunes for the wealthiest of those who wished to look beyond the veil. But after years of inquiring on behalf of others, she began to seek clues on her own fate. When death refused to yield its secrets, she tried to buy them with her life. But the ultimate price proved insufficient. Death disgorged her again and again, always holding back its deepest mysteries. </p>
</div>
</div>
</a>
</div>
</div>
</li>
<li>
<div class="flip">
<div class="front-side"></div>
<div class="back-side">
<a href="#">
<div class="content">
<div class="loader"></div>
<div class="text">
<h3>KATARINA</h3>
<p>Driven by an intense killer instinct, Katarina uses her talents as an assassin for the glory of Noxus, and the continued elevation of her family. While her fervor drives her to ever-greater feats, it can sometimes lead her astray.</p>
</div>
</div>
</a>
</div>
</div>
</li>
<li>
<div class="flip">
<div class="front-side"></div>
<div class="back-side">
<a href="#">
<div class="content">
<div class="loader"></div>
<div class="text">
<h3>VENGEFUL SPIRIT</h3>
<p>Even the most contented Skywrath is an ill-tempered creature, naturally inclined to seek revenge for the slightest insult. But Vengeful Spirit is the essence of vengeance. Once a proud and savage Skywrath scion, Shendelzare was first in succession for the Ghastly Eyrie until a sister's treachery robbed her of her birthright. Snared in an assassin's net, Shendelzare tore free only at the cost of her wings, limping away in the ultimate humiliation: On foot. With her wings broken, she knew the Skywrath would never accept her as ruler; and in the highest roost of the Eyrie, inaccessible except by winged flight, her sister was untouchable.</p>
</div>
</div>
</a>
</div>
</div>
</li>
<li>
<div class="flip">
<div class="front-side"></div>
<div class="back-side">
<a href="#">
<div class="content">
<div class="loader"></div>
<div class="text">
<h3>LINA</h3>
<p>The sibling rivalries between Lina the Slayer, and her younger sister Rylai, the Crystal Maiden, were the stuff of legend in the temperate region where they spent their quarrelsome childhoods together. Lina always had the advantage, however, for while Crystal was guileless and naive, Lina's fiery ardor was tempered by cleverness and conniving. The exasperated parents of these incompatible offspring went through half a dozen homesteads, losing one to fire, the next to ice, before they realized life would be simpler if the children were separated.</p>
</div>
</div>
</a>
</div>
</div>
</li>
</ul>
</div>
@import "https://fonts.googleapis.com/css?family=Open+Sans";
html {
height: 100%;
}
body {
background: #181818;
color: #F0F3F4;
font: normal 16px/1.25 'Open Sans';
min-height: 100%;
height: 100%;
overflow: hidden;
}
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
a {
text-decoration: none;
}
.container {
height: 100%;
}
.gallery {
list-style-type: none;
height: 100%;
overflow: hidden;
}
.gallery li {
float: left;
height: 100%;
width: 400px;
background: #2E4053;
}
.gallery .flip {
height: 100%;
width: 100%;
position: relative;
-webkit-transform-style: preserve-3d;
-moz-transform-style: preserve-3d;
transform-style: preserve-3d;
-webkit-perspective: 2000px;
-moz-perspective: 2000px;
perspective: 2000px;
}
.gallery li:hover .front-side {
opacity: 0;
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
transform: rotateY(180deg);
}
.gallery li:hover .back-side {
background: #000;
opacity: 1;
-webkit-transform: rotateY(0deg);
-moz-transform: rotateY(0deg);
transform: rotateY(0deg);
}
.gallery .front-side,
.gallery .back-side {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
backface-visibility: hidden;
-webkit-transition: transform 0.4s ease-out, opacity 0.3s ease-out;
-moz-transition: transform 0.4s ease-out, opacity 0.3s ease-out;
transition: transform 0.4s ease-out, opacity 0.3s ease-out;
}
.gallery .front-side {
opacity: 1;
background-size: cover;
background-repeat: no-repeat;
background-position: 50% 50%;
-webkit-transform: rotateY(0deg);
-moz-transform: rotateY(0deg);
transform: rotateY(0deg);
}
.gallery .back-side {
opacity: 0;
-webkit-transform: rotateY(-180deg);
-moz-transform: rotateY(-180deg);
transform: rotateY(-180deg);
}
.gallery .back-side > a {
display: block;
width: 100%;
height: 100%;
}
.gallery li:nth-child(1) .front-side {
background-image:url('http://pre12.deviantart.net/f04f/th/pre/i/2015/281/c/e/virtus_pro_tribute_by_haryarti-d9cdvwy.jpg');
}
.gallery li:nth-child(1) .loader {
border-top-color: #F39C12;
border-left-color: #F39C12;
}
.gallery li:nth-child(1) .text h3 {
color: #F39C12;
}
.gallery li:nth-child(1) .text h3:after {
background: #F5B041;
}
.gallery li:nth-child(2) .front-side {
background-image: url('http://pre06.deviantart.net/f121/th/pre/i/2014/280/7/a/crystal_maiden_by_haryarti-d81xgfl.jpg');
}
.gallery li:nth-child(3) .front-side {
background-image: url('http://pre10.deviantart.net/3566/th/pre/i/2014/289/5/a/drow_ranger_by_haryarti-d83292f.jpg');
}
.gallery li:nth-child(3) .loader {
border-top-color: #424949;
border-left-color: #424949;
}
.gallery li:nth-child(3) .text h3 {
color: #424949;
}
.gallery li:nth-child(3) .text h3:after {
background: #515A5A;
}
.gallery li:nth-child(4) .front-side {
background-image: url('http://pre01.deviantart.net/c319/th/pre/i/2014/322/e/a/windrunner_by_haryarti-d86ubud.jpg');
}
.gallery li:nth-child(4) .loader {
border-top-color: #F1C40F;
border-left-color: #F1C40F;
}
.gallery li:nth-child(4) .text h3 {
color: #F1C40F;
}
.gallery li:nth-child(4) .text h3:after {
background: #F7DC6F;
}
.gallery li:nth-child(5) .front-side {
background-image: url('http://pre04.deviantart.net/5815/th/pre/f/2014/149/7/7/death_prophet_from_dota_2_by_o_l_i_v_i-d7k2ekl.jpg');
}
.gallery li:nth-child(5) .loader {
border-top-color: #1ABC9C;
border-left-color: #1ABC9C;
}
.gallery li:nth-child(5) .text h3 {
color: #1ABC9C;
}
.gallery li:nth-child(5) .text h3:after {
background: #48C9B0;
}
.gallery li:nth-child(6) .front-side {
background-image: url('http://pre02.deviantart.net/ce96/th/pre/i/2015/177/7/7/katarina_by_haryarti-d8ytd5o.jpg');
}
.gallery li:nth-child(6) .loader {
border-top-color: #E74C3C;
border-left-color: #E74C3C;
}
.gallery li:nth-child(6) .text h3 {
color: #E74C3C;
}
.gallery li:nth-child(6) .text h3:after {
background: #EC7063;
}
.gallery li:nth-child(7) .front-side {
background-image: url('http://pre10.deviantart.net/cbaf/th/pre/i/2015/047/0/2/vengeful_spirit_by_haryarti-d8iau4i.png');
}
.gallery li:nth-child(7) .loader {
border-top-color: #8E44AD;
border-left-color: #8E44AD;
}
.gallery li:nth-child(7) .text h3 {
color: #8E44AD;
}
.gallery li:nth-child(7) .text h3:after {
background: #A569BD;
}
.gallery li:nth-child(8) .front-side {
background-image: url('http://pre06.deviantart.net/73a2/th/pre/i/2014/080/5/7/lina_by_haryarti-d7b48eu.jpg');
}
.gallery li:nth-child(8) .loader {
border-top-color: #F39C12;
border-left-color: #F39C12;
}
.gallery li:nth-child(8) .text h3 {
color: #F39C12;
}
.gallery li:nth-child(8) .text h3:after {
background: #F5B041;
}
.gallery .content {
text-align: center;
position: relative;
top: 50%;
-webkit-transform: translateY(-50%);
-moz-transform: translateY(-50%);
transform: translateY(-50%);
padding: 25px 20px;
}
.gallery li:hover .text {
opacity: 1;
visibility: visible;
max-height: 2000px;
-webkit-transition: opacity .3s ease-in 1.5s, max-height .1s ease 1.5s;
-moz-transition: opacity .3s ease-in 1.5s, max-height .1s ease 1.5s;
transition: opacity .3s ease-in 1.5s, max-height .1s ease 1.5s;
}
.gallery li:hover .loader {
opacity: 1;
visibility: visible;
-webkit-animation: hide .1s ease-in-out 1.4s forwards, load .75s infinite;
-moz-animation: hide .1s ease-in-out 1.4s forwards, load .75s infinite;
animation: hide .1s ease-in-out 1.4s forwards, load .75s infinite;
}
.gallery .text {
opacity: 0;
visibility: hidden;
max-height: 0;
}
.gallery .content h3 {
position: relative;
color: #3498DB;
font: normal 30px/1.25 'Open Sans';
margin-bottom: 25px;
}
.gallery .content h3:after {
content: '';
position: absolute;
width: 50px;
height: 3px;
bottom: -10px;
left: 50%;
margin-left: -25px;
background: #85C1E9;
}
.gallery .content p {
margin: 10px 0;
color: #D6DBDF;
font: normal 16px/1.25 'Open Sans';
}
.gallery .loader {
opacity: 0;
visibility: hidden;
width: 30px;
height: 30px;
border-radius: 50%;
margin: auto;
border: 4px solid transparent;
border-top-color: #3498DB;
border-left-color: #3498DB;
}
@-webkit-keyframes load {
0% {
-webkit-transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
}
}
@-moz-keyframes load {
0% {
-moz-transform: rotate(0deg);
}
100% {
-moz-transform: rotate(360deg);
}
}
@keyframes load {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@-webkit-keyframes hide {
100% {
visibility: hidden;
opacity: 0;
}
}
@-moz-keyframes hide {
100% {
visibility: hidden;
opacity: 0;
}
}
@keyframes hide {
100% {
visibility: hidden;
opacity: 0;
}
}
var Gallery = (function() {
var colors = ['#34495E', '#2E4053', '#283747', '#212F3C', '#1B2631', '#2C3E50', '#273746'];
var scrollTimeId;
var posLeft = 0;
function Gallery(config) {
this.list = $(config.list);
this.items = this.list.find('li');
this.itemWidth = this.items.outerWidth();
};
Gallery.prototype = {
constructor: Gallery,
init: function() {
this.setGalleryWidth();
this.setItemsColor();
this.eventManager();
return this;
},
eventManager: function() {
var _this = this;
$("html, body").on('mousewheel', function(event) {
clearTimeout(scrollTimeId);
scrollTimeId = setTimeout(onScrollEventHandler.bind(this, event, _this.itemWidth), 0);
});
},
getRandomColor: function() {
return colors[Math.floor(Math.random() * colors.length)];
},
setItemsColor: function() {
var _this = this;
$.each(this.items, function(index, item) {
item.style.backgroundColor = _this.getRandomColor();
});
},
setGalleryWidth: function() {
this.list.css('width', this.getGalleryWidth());
},
getGalleryWidth: function() {
var width = 0;
this.items.each(function(index, item) {
width += $(this).outerWidth();
});
return width;
}
};
function onScrollEventHandler(event, width) {
if (event.deltaY > 0) {
this.scrollLeft -= width / 2;
} else {
this.scrollLeft += width / 2;
}
// Firefox, please, stop it
// if (navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
// if (event.originalEvent.detail > 0) {
// posLeft += width / 2;
// $('html').scrollLeft(posLeft);
// } else {
// posLeft -= width / 2;
// $('html').scrollLeft(posLeft);
// }
// } else {
// if (event.originalEvent.wheelDelta > 0) {
// this.body.scrollLeft -= width / 2;
// } else {
// this.body.scrollLeft += width / 2;
// }
// }
event.preventDefault();
};
return Gallery;
})();
$(document).ready(function() {
var gallery = new Gallery({
list: '.gallery'
}).init();
});
Also see: Tab Triggers