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="card-movie-wrapper card-movie-wrapper--centered">
<div class="card-movie-carousel">
<div class="card-movie card-movie--light card-movie--looper card-movie--active">
<div class="card-movie__content">
<div class="card-movie__title">Looper</div>
<div class="card-movie__details">
<span class="card-movie__details-item">2012</span>
<span class="card-movie__details-item">119 mins</span>
<ul class="card-movie__details-item card-movie__details-list">
<li>Action</li>
<li>Crime</li>
<li>Sci-fi</li>
</ul>
</div>
<!-- /.card-movie__details -->
<div class="card-movie__description">
<p>In 2074, when the mob wants to get rid of someone, the target is sent into the past, where a hired gun awaits - someone like Joe.</p>
</div>
<!-- /.card-movie__description -->
</div>
<!-- /.card-movie__content -->
<div class="card-movie__rating">7.5</div>
<div class="card-movie__player" data-trailer="5kGFyVKmqA0">
</div>
<!-- /.card-movie__player -->
</div>
<!-- /.card-movie card-movie--looper -->
<div class="card-movie card-movie--dark card-movie--tron">
<div class="card-movie__content">
<div class="card-movie__title">Tron: Legacy</div>
<div class="card-movie__details">
<span class="card-movie__details-item">2010</span>
<span class="card-movie__details-item">125 mins</span>
<ul class="card-movie__details-item card-movie__details-list">
<li>Action</li>
<li>Adventure</li>
<li>Fantasy</li>
<li>Sci-fi</li>
</ul>
</div>
<!-- /.card-movie__details -->
<div class="card-movie__description">
<p>The son of a virtual world designer goes looking for his father and ends up inside the digital world that his father designed. He meets his father's corrupted creation and a unique ally who was born inside the digital world.</p>
</div>
<!-- /.card-movie__description -->
</div>
<!-- /.card-movie__content -->
<div class="card-movie__rating">6.8</div>
<div class="card-movie__player" data-trailer="L9szn1QQfas">
</div>
<!-- /.card-movie__player -->
</div>
<!-- /.card-movie card-movie--tron -->
<div class="card-movie card-movie--light card-movie--garden-state">
<div class="card-movie__content">
<div class="card-movie__title">Garden State</div>
<div class="card-movie__details">
<span class="card-movie__details-item">2004</span>
<span class="card-movie__details-item">102 mins</span>
<ul class="card-movie__details-item card-movie__details-list">
<li>Comedy</li>
<li>Drama</li>
<li>Romance</li>
</ul>
</div>
<!-- /.card-movie__details -->
<div class="card-movie__description">
<p>A quietly troubled young man returns home for his mother's funeral after being estranged from his family for a decade.</p>
</div>
<!-- /.card-movie__description -->
</div>
<!-- /.card-movie__content -->
<div class="card-movie__rating">7.6</div>
<div class="card-movie__player" data-trailer="u82n0e1mgmQ">
</div>
<!-- /.card-movie__player -->
</div>
<!-- /.card-movie card-movie--garden-state -->
<div class="card-movie card-movie--light card-movie--interstellar">
<div class="card-movie__content">
<div class="card-movie__title">Interstellar</div>
<div class="card-movie__details">
<span class="card-movie__details-item">2014</span>
<span class="card-movie__details-item">169 mins</span>
<ul class="card-movie__details-item card-movie__details-list">
<li>Adventure</li>
<li>Drama</li>
<li>Sci-fi</li>
</ul>
</div>
<!-- /.card-movie__details -->
<div class="card-movie__description">
<p>With our time on Earth coming to an end, a team of explorers undertakes the most important mission in human history; traveling beyond this galaxy to discover whether mankind has a future among the stars.</p>
</div>
<!-- /.card-movie__description -->
</div>
<!-- /.card-movie__content -->
<div class="card-movie__rating">8.7</div>
<div class="card-movie__player" data-trailer="3WzHXI5HizQ">
</div>
<!-- /.card-movie__player -->
</div>
<!-- /.card-movie card-movie--interstellar -->
<div class="card-movie card-movie--light card-movie--walter-mitty">
<div class="card-movie__content">
<div class="card-movie__title">Walter Mitty</div>
<div class="card-movie__details">
<span class="card-movie__details-item">2013</span>
<span class="card-movie__details-item">114 mins</span>
<ul class="card-movie__details-item card-movie__details-list">
<li>Adventure</li>
<li>Comedy</li>
<li>Drama</li>
</ul>
</div>
<!-- /.card-movie__details -->
<div class="card-movie__description">
<p>When his job along with that of his co-worker are threatened, Walter takes action in the real world embarking on a global journey that turns into an adventure more extraordinary than anything he could have ever imagined.</p>
</div>
<!-- /.card-movie__description -->
</div>
<!-- /.card-movie__content -->
<div class="card-movie__rating">7.4</div>
<div class="card-movie__player" data-trailer="QD6cy4PBQPI">
</div>
<!-- /.card-movie__player -->
</div>
<!-- /.card-movie card-movie--walter-mitty -->
<div class="card-movie card-movie--dark card-movie--cloud-atlas">
<div class="card-movie__content">
<div class="card-movie__title">Cloud Atlas</div>
<div class="card-movie__details">
<span class="card-movie__details-item">2012</span>
<span class="card-movie__details-item">172 mins</span>
<ul class="card-movie__details-item card-movie__details-list">
<li>Drama</li>
<li>Sci-Fi</li>
</ul>
</div>
<!-- /.card-movie__details -->
<div class="card-movie__description">
<p>An exploration of how the actions of individual lives impact one another in the past, present and future, as one soul is shaped from a killer into a hero, and an act of kindness ripples across centuries to inspire a revolution.</p>
</div>
<!-- /.card-movie__description -->
</div>
<!-- /.card-movie__content -->
<div class="card-movie__rating">7.5</div>
<div class="card-movie__player" data-trailer="hWnAqFyaQ5s">
</div>
<!-- /.card-movie__player -->
</div>
<!-- /.card-movie card-movie--cloud-atlas -->
</div>
<!-- /.card-movie-carousel -->
<div class="card-movie-navigation">
<ul class="card-movie-navigation__list" data-navigation>
<li class="is-active"></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
<!-- /.card-movie-navigation__list -->
<button type="button" data-play></button>
</div>
<!-- /.card-movie-navigation -->
</div>
<!-- /.card-movie-wrapper -->
$color-white: #fff;
$color-black: #000;
$transition-time: 250ms;
$transition-method: ease-in-out;
$card-height: 440px;
$card-width: 840px;
$card-hover-offset-x: 40px;
$card-hover-offset-y: 60px;
html {
box-sizing: border-box;
}
// html
body {
color: #676767;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 12px;
line-height: 1.5;
}
// body
*,
*:before,
*:after {
box-sizing: inherit;
line-height: inherit;
}
// *, *:before, *:after
%clearfix {
&:after {
clear: both;
content: '';
display: table;
}
// &:after
}
// %clearfix
.card-movie-wrapper {
box-shadow: 0px 0px 100px 25px rgba($color-black, 0.2);
height: $card-height;
position: relative;
width: $card-width;
&:hover {
.card-movie-carousel {
-webkit-transition: all $transition-time $transition-method;
-moz-transition: all $transition-time $transition-method;
transition: all $transition-time $transition-method;
bottom: $card-hover-offset-y;
right: $card-hover-offset-x;
}
// .card-movie-carousel
}
// &:hover
}
// .card-movie-wrapper
.card-movie-wrapper--centered {
-webkit-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
-o-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
left: 50%;
position: absolute;
top: 50%;
}
// .card-movie-wrapper--centered
.card-movie-carousel {
-webkit-transition: all $transition-time $transition-method 250ms;
-moz-transition: all $transition-time $transition-method 250ms;
transition: all $transition-time $transition-method 250ms;
height: $card-height;
width: $card-width;
position: absolute;
bottom: 0;
right: 0;
overflow: hidden;
}
.card-movie-navigation {
background-color: $color-white;
bottom: 0;
height: 100%;
overflow: hidden;
position: absolute;
right: 0;
width: 100%;
z-index: 15;
&__list {
$item-size: 12px;
$item-size-active: $item-size * 1.5;
-webkit-transform: translateY(-50%);
-moz-transform: translateY(-50%);
-ms-transform: translateY(-50%);
-o-transform: translateY(-50%);
transform: translateY(-50%);
position: absolute;
right: ($card-hover-offset-x - $item-size) / 2;
top: 50%;
width: $item-size-active;
li {
-webkit-transition: all $transition-time $transition-method;
-moz-transition: all $transition-time $transition-method;
transition: all $transition-time $transition-method;
background-color: #ccc;
border-radius: 100%;
cursor: pointer;
height: $item-size;
margin: 0 auto $item-size/2;
width: $item-size;
&:last-child {
margin-bottom: 0;
}
// &:last-child
&.is-active {
height: $item-size-active;
width: $item-size-active;
}
// &.is-active
&:hover {
background-color: #bbb;
}
// &:hover
}
// li
}
// &__list
button {
$arrow-size: 6px;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
background-color: transparent;
border: none;
bottom: 0;
color: #aac8ca;
cursor: pointer;
font-size: 14px;
line-height: $card-hover-offset-y;
margin: 0;
outline: none;
padding: 0;
position: absolute;
right: $card-hover-offset-x;
&:before {
content: 'Watch Trailer';
}
// &:before
&:after {
-webkit-transform: translateY(-50%);
-moz-transform: translateY(-50%);
-ms-transform: translateY(-50%);
-o-transform: translateY(-50%);
transform: translateY(-50%);
border-bottom: $arrow-size solid transparent;
border-left: $arrow-size solid #dce9e9;
border-top: $arrow-size solid transparent;
content: '';
height: 0;
margin-right: $arrow-size;
position: absolute;
right: 100%;
top: 50%;
width: 0;
}
// &:after
&.is-playing {
&:before {
content: 'Hide Trailer';
}
// &:before
&:after {
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
transform: rotate(-90deg);
margin-top: -$arrow-size;
}
// &:after
}
// &.is-playing
}
// button
}
// .card-movie-navigation
.card-movie {
-webkit-transition: all ($transition-time * 2) $transition-method;
-moz-transition: all ($transition-time * 2) $transition-method;
transition: all ($transition-time * 2) $transition-method;
background-size: cover;
bottom: 0;
height: 100%;
overflow: hidden;
position: absolute;
right: 0;
opacity: 0;
width: 100%;
z-index: 20;
&__content {
left: 330px;
position: absolute;
top: 150px;
}
// &__content
&__title {
font-size: 60px;
font-weight: 700;
line-height: 1;
margin-left: -4px;
text-transform: uppercase;
}
// &__title
&__details {
@extend %clearfix;
margin-bottom: 30px;
margin-top: 15px;
&-item {
display: block;
float: left;
margin-right: 20px;
}
// &-item
&-list {
@extend %clearfix;
li {
float: left;
margin-right: 5px;
padding-right: 6px;
position: relative;
&:after {
content: '|';
position: absolute;
right: 0;
}
// &:after
&:last-child {
margin-right: 0;
&:after {
display: none;
}
// &:after
}
// &:last-child
}
// li
}
// &-list
}
// &__details
&__description {
font-size: 14px;
max-width: 390px;
}
// &__description
&__rating {
$size: 50px;
bottom: $size/3;
font-size: 18px;
font-weight: 700;
line-height: $size;
position: absolute;
right: $size/3;
text-align: center;
width: $size;
&:after {
border-radius: 100%;
border: 2px solid #ee927b;
content: '';
height: 100%;
left: 0;
position: absolute;
top: 0;
width: 100%;
}
// &:after
}
// &__rating
&__player {
-webkit-transition: all ($transition-time * 2) $transition-method;
-moz-transition: all ($transition-time * 2) $transition-method;
transition: all ($transition-time * 2) $transition-method;
-webkit-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
-o-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
height: 0;
left: 50%;
position: absolute;
top: 50%;
width: 0;
z-index: 20;
.card-movie--playing & {
height: $card-height;
width: $card-width;
}
// .card-movie--playing &
iframe {
height: 100%;
width: 100%;
}
// iframe
}
// &__player
}
// .card-movie
.card-movie--active {
opacity: 1;
z-index: 25;
}
// .card-movie--active
.card-movie--light {
background-color: #effdfd;
[class*='__title'] {
color: $color-black;
}
// [class*='__title']
}
// .card-movie--light
.card-movie--dark {
background-color: $color-black;
color: #fff;
[class*='__title'] {
color: #fff;
}
// [class*='__title']
}
// .card-movie--dark
.card-movie--looper {
background-image: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/43525/looper.png');
}
// .card-movie--looper
.card-movie--tron {
background-image: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/43525/tron.png');
}
// .card-movie--tron
.card-movie--interstellar {
background-image: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/43525/interstellar.png');
background-color: #fffffa;
}
// .card-movie--interstellar
.card-movie--garden-state {
background-image: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/43525/garden-state.png');
}
// .card-movie--garden-state
.card-movie--walter-mitty {
background-image: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/43525/walter-mitty.png');
}
// .card-movie--walter-mitty
.card-movie--cloud-atlas {
background-image: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/43525/cloud-atlas.png');
}
// .card-movie--cloud-atlas
// global vars
var players = [],
current = 0;
// YouTube iFrame API Ready
function onYouTubeIframeAPIReady() {
$('[data-trailer]').each(function() {
var player,
id = $(this).data('trailer');
$(this).html('<iframe id="player_' + id + '" src="https://www.youtube.com/embed/' + id + '?enablejsapi=1&autohide=1&showinfo=0&theme=light" frameborder="0" allowfullscreen></iframe>');
player = new YT.Player('player_' + id, {
events: {
'onStateChange': onPlayerStateChange
}
});
players.push(player);
});
}
// YouTube On Player State Change
function onPlayerStateChange(event) {
var player = players[current];
switch(event.data) {
case YT.PlayerState.ENDED:
player.stopVideo();
player.seekTo(0);
$('.card-movie--playing').removeClass('card-movie--playing');
$('[data-play]').removeClass('is-playing');
; break;
}
}
$(function() {
$('[data-play]').on('click', function() {
var $card = $('.card-movie--active'),
player = players[$card.index()];
if ($card.hasClass('card-movie--playing')) {
$(this).toggleClass('is-playing');
player.pauseVideo();
} else {
$(this).toggleClass('is-playing');
player.playVideo();
}
$card.toggleClass('card-movie--playing');
});
$('[data-navigation] li').on('click', function() {
// remove current stuff
players[current].pauseVideo();
$('.card-movie:eq(' + current + ')').removeClass('card-movie--playing card-movie--active');
$('[data-play]').removeClass('is-playing');
// assign new current
current = $(this).index();
$(this).addClass('is-active').siblings().removeClass('is-active');
$('.card-movie:eq(' + current + ')').addClass('card-movie--active');
});
});
Also see: Tab Triggers