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 id="app">
<section class="hero is-primary is-medium">
<router-view></router-view>
<div class="hero-foot">
<div class="columns is-mobile">
<div v-for="movieChoice in movieChoices" class="column">
<router-link :to="`/${movieChoice.id}`" tag="li" class="movie-choice">
<i :class="[{ 'fa fa-check-circle favorite-check': movieChoice.favorite }]" aria-hidden="true"></i>
<img :src="`${movieChoice.smallImgSrc}`" class="desktop"/>
<p class="mobile movie-title">{{ movieChoice.subtitle }}</p>
</router-link>
</div>
</div>
</div>
</section>
<p class="appreciation-tag">
Inspired by @makv25's <a href="https://dribbble.com/shots/3720358-Daily-Ui-025-TV-app" target="_blank">daily dribble</a>
</p>
<a href="https://hackernoon.com/building-a-movie-app-interface-with-vue-js-cdc8aeb5db0b" target="_blank" class="medium-section button is-small"><i class="fa fa-medium" aria-hidden="true"></i>
<a>
<a href="https://twitter.com/djirdehh" target="_blank" class="twitter-section">
<i class="fa fa-twitter-square" aria-hidden="true"></i>
<a>
</div>
// Best viewed in full page view
// https://codepen.io/itslit/full/MvvjZr
$small: 589px;
$medium: 767px;
$large: 1023px;
html, body {
height: 100%;
background: linear-gradient(to bottom right,#7f3737,#2a2122);
@extend .vertical-align;
.hero {
@media screen and (max-width: $medium) {
max-width: 536px;
}
background: #1e1d1d !important;
position: relative;
max-width: 1021px;
box-shadow: 0 0 50px 5px rgba(0,0,0,.25);
.hero-body {
background-color: rgba(0,0,0,0.7);
background-blend-mode: multiply;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
padding-bottom: 4rem !important;
padding-top: 4.5rem !important;
@media screen and (max-width: $medium) {
background-color: rgba(0,0,0,0.8);
}
.container {
width: 100%;
.home-intro {
font-size: 60px;
letter-spacing: 8px;
color: red;
text-align: center;
text-transform: uppercase;
}
}
.nav {
position: absolute;
top: 10px;
width: 100%;
box-shadow: 0px 0px 0px !important;
.nav-item {
.fa-bars {
color: #ce2424;
font-size: 40px;
}
.tag {
font-size: 15px;
}
.title {
color: red;
font-size: 18px;
font-weight: 600;
text-align: center;
text-transform: uppercase;
}
}
.nav-right {
.nav-item {
float: right;
}
}
}
.column {
padding-left: 50px;
min-height: 264px;
.title {
font-size: 45px;
font-weight: 600;
@media screen and (max-width: $medium) {
font-size: 35px;
}
}
.subtitle {
font-size: 15px;
font-weight: 600;
color: red;
@media screen and (max-width: $medium) {
font-size: 14px;
}
.subtitle-tag {
display: inline;
}
}
.description {
font-size: 15px;
margin-bottom: 24px;
max-width: 450px;
}
.links {
.play-button {
background: #ce2424;
color: #FFF;
border-radius: 15px;
border: 0px;
margin-right: 20px;
padding: 15px;
.fa-play {
padding-left: 7px;
}
@media screen and (max-width: $medium) {
font-size: 14px;
}
}
.favorites-button {
text-decoration: none;
color: #FFF;
&:hover {
background: none;
text-decoration: none;
}
.fa-plus-square-o {
padding-left: 10px;
padding-top: 2px;
}
@media screen and (max-width: $medium) {
background: #FFF;
color: #4a4a4a;
border-radius: 15px;
font-size: 14px;
&:hover {
background: #FFF;
}
}
}
@media screen and (max-width: $medium) {
text-align: center;
}
}
}
}
.trailer-body {
padding: 0;
height: 376px;
}
.hero-foot {
background: linear-gradient(to bottom right, #7d1e24, #bb2d35);
.columns {
padding: 20px;
padding-bottom: 30px;
text-align: center;
.movie-choice {
position: relative;
list-style: none;
cursor: pointer;
.favorite-check {
position: absolute;
right: 5px;
top: 5px;
z-index: 1;
color: #fcff4c;
@media(max-width: $medium) {
position: initial;
display: block;
}
}
img {
opacity: 0.9;
}
.movie-title {
&:active {
font-weight: 600;
}
}
}
}
}
}
.appreciation-tag {
color: #FFF;
text-align: center;
a {
color: #ce2424;
font-weight: 600;
}
}
.twitter-section {
position: absolute;
right: 10px;
bottom: 10px;
.fa-twitter-square {
color: #FFF;
font-size: 30px;
}
}
.medium-section {
position: absolute;
left: 10px;
bottom: 10px;
.fa-medium {
font-size: 15px;
}
}
// Miscellaneous
.vertical-align {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
flex-direction: column;
align-items: center;
-webkit-align-items: center;
justify-content: center;
-webkit-justify-content: center;
}
.movie-title-active {
font-size: 18px;
font-weight: 600;
}
.iframe-box {
max-width: 1280px; /* video width */
max-height: 720px; /* video height */
}
.favorite-shadow {
box-shadow: 0 0 50px 15px rgba(251, 255, 15, 0.25);
}
.desktop {
display: block;
@media screen and (max-width: $medium) {
display: none;
}
}
.mobile {
display: none;
@media screen and (max-width: $medium) {
display: block;
}
}
.hide {
display: none;
}
}
const movies = {
"dunkirk": {
"id": 'dunkirk',
"title": "Dunkirk",
"subtitle": "Dunkirk",
"description": `Miraculous evacuation of Allied soldiers from Belgium, Britain, Canada, and France, who were cut off and surrounded by the German army from the beaches and harbor of Dunkirk, France, during the Battle of France in World War II.`,
"largeImgSrc": `url('https://image.tmdb.org/t/p/w780/fudEG1VUWuOqleXv6NwCExK0VLy.jpg')`,
"smallImgSrc": 'https://image.tmdb.org/t/p/w185/fudEG1VUWuOqleXv6NwCExK0VLy.jpg',
"releaseDate": 'July 21 2017',
"duration": '1hr 46min',
"genre": 'Action, Drama, History',
"trailerPath": 'https://www.youtube.com/embed/F-eMt3SrfFU',
"favorite": false
},
"interstellar": {
"id": 'interstellar',
"title": "Interstellar",
"subtitle": "Interstellar",
"description": `Interstellar chronicles the adventures of a group of explorers who make use of a newly discovered wormhole to surpass the limitations on human space travel and conquer the vast distances involved in an interstellar voyage.`,
"largeImgSrc": `url('https://image.tmdb.org/t/p/w780/xu9zaAevzQ5nnrsXN6JcahLnG4i.jpg')`,
"smallImgSrc": 'https://image.tmdb.org/t/p/w185/xu9zaAevzQ5nnrsXN6JcahLnG4i.jpg',
"releaseDate": 'November 7 2014',
"duration": '2hr 49min',
"genre": 'Adventure, Drama',
"trailerPath": 'https://www.youtube.com/embed/zSWdZVtXT7E',
"favorite": false
},
"the-dark-knight-rises": {
"id": 'the-dark-knight-rises',
"title": "The Dark Knight Rises",
"subtitle": "TDKR",
"description": `Batman encounters the mysterious Selina Kyle and the villainous Bane, a new terrorist leader who overwhelms Gotham's finest. The Dark Knight resurfaces to protect a city that has branded him an enemy.`,
"smallImgSrc": 'https://image.tmdb.org/t/p/w185/3bgtUfKQKNi3nJsAB5URpP2wdRt.jpg',
"largeImgSrc": `url('https://image.tmdb.org/t/p/w780/3bgtUfKQKNi3nJsAB5URpP2wdRt.jpg')`,
"releaseDate": 'July 20 2012',
"duration": '2hr 44min',
"genre": 'Action, Thriller',
"trailerPath": 'https://www.youtube.com/embed/g8evyE9TuYk',
"favorite": false
},
"inception": {
"id": 'inception',
"title": "Inception",
"subtitle": "Inception",
"description": `Cobb, a skilled thief is offered a chance to regain his old life as payment for a task considered to be impossible: \"inception\", the implantation of another person's idea into a target's subconscious.`,
"smallImgSrc": 'https://image.tmdb.org/t/p/w185/s2bT29y0ngXxxu2IA8AOzzXTRhd.jpg',
"largeImgSrc": `url('https://image.tmdb.org/t/p/w780/s2bT29y0ngXxxu2IA8AOzzXTRhd.jpg')`,
"releaseDate": 'July 10 2010',
"duration": '2hr 28min',
"genre": 'Action, Adventure, Sci-Fi',
"trailerPath": 'https://www.youtube.com/embed/8hP9D6kZseM',
"favorite": false
},
"the-prestige": {
"id": 'the-prestige',
"title": "The Prestige",
"subtitle": "Prestige",
"description": `A mysterious story of two magicians whose intense rivalry leads them on a life-long battle for supremacy - to create the ultimate illusion whilst sacrificing everything they have to outwit the other.`,
"smallImgSrc": 'https://image.tmdb.org/t/p/w185/c5o7FN2vzI7xlU6IF1y64mgcH9E.jpg',
"largeImgSrc": `url('https://image.tmdb.org/t/p/w780/c5o7FN2vzI7xlU6IF1y64mgcH9E.jpg')`,
"releaseDate": 'October 20 2006',
"duration": '2hr 10min',
"genre": 'Drama, Mystery, Sci-Fi',
"trailerPath": 'https://www.youtube.com/embed/ijXruSzfGEc',
"favorite": false
}
}
// 1. Define route components.
const Intro = {
template: `
<div class="hero-body" style="background: #1e1d1d">
<div class="container has-text-centered">
<div class="columns">
<div class="column is-half is-offset-one-quarter vertical-align">
<h1 class="home-intro">
VueFlix
</h1>
<p class="home-subintro">Select a movie below from the list of critically acclaimed Christopher Nolan films.</p>
</div>
</div>
</div>
</div>`
}
const Movie = {
template:
`<div :class="[{ 'favorite-shadow': selectedMovie.favorite }, 'hero-body']" :style="{ 'background-image': selectedMovie.largeImgSrc }">
<header class="nav">
<div class="container">
<div class="nav-left">
<a class="nav-item">
<i class="fa fa-bars" aria-hidden="true"></i>
</a>
<router-link to="/" class="nav-item is-active">
Home
</router-link>
<a class="nav-item is-active">
<span class="tag is-rounded">
Films
</span>
</a>
<a class="nav-item is-active">
Shows
</a>
<a class="nav-item is-active">
Music
</a>
</div>
<div class="nav-right desktop">
<span class="nav-item">
<router-link to="/" class="title">
VueFlix
</router-link>
</span>
</div>
</div>
</header>
<div class="container description-container">
<div class="columns">
<div class="column is-three-quarters">
<h1 class="title">
{{ selectedMovie.title }}
</h1>
<h4 class="subtitle">
<p class="subtitle-tag">{{ selectedMovie.duration }} |</p>
<p class="subtitle-tag">{{ selectedMovie.genre }} |</p>
<p class="subtitle-tag">{{ selectedMovie.releaseDate }}</p>
</h4>
<p class="description">{{ selectedMovie.description }}</p>
<div class="links">
<router-link :to="{path: '/' + $route.params.id + '/trailer'}" class="button play-button">Play <i class="fa fa-play"></i></router-link>
<a class="button is-link favorites-button" @click="addToFavorites(selectedMovie)">
<span :class="[{ 'hide': selectedMovie.favorite }]">Add to</span><span :class="[{ 'hide': !selectedMovie.favorite }]">Remove from </span> favorites <i class="fa fa-plus-square-o"></i>
</a>
</div>
</div>
</div>
</div>
</div>`,
data () {
return {
selectedMovie: movies[this.$route.params.id]
}
},
watch: {
$route () {
this.selectMovie()
}
},
methods: {
selectMovie () {
this.selectedMovie = movies[this.$route.params.id]
},
addToFavorites (selectedMovie) {
movies[this.$route.params.id].favorite = !movies[this.$route.params.id].favorite
}
}
}
const MovieTrailer = {
template: `
<div class="trailer-body" style="background: #1e1d1d">
<div class="has-text-centered">
<div class="columns">
<div class="column vertical-align">
<iframe
allowFullScreen
frameborder="0"
height="376"
:src="trailerUrlPath"
style="width: 100%; min-width: 536px"
/>
</div>
</div>
</div>
</div>`,
data () {
return {
trailerUrlPath: movies[this.$route.params.id].trailerPath
}
}
}
// 2. Define routes
const routes = [
{ path: '/', component: Intro },
{ path: '/:id', component: Movie },
{ path: '/:id/trailer', component: MovieTrailer }
]
const router = new VueRouter({
routes
})
const rootApp = new Vue({
el: '#app',
router: router,
data () {
return {
movieChoices: movies
}
},
})
Also see: Tab Triggers