Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

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.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <div id="header" class="cf">
  	<div class="page-width">
    		<h1 id="site-title">
      			<a href="" target="_blank">
				        <span class="title">BG Stock</span>
				        <span class="subtitle">HTML5 Background Videos</span>

<!-- Start video hero -->
<div class="video-hero jquery-background-video-wrapper demo-video-wrapper">
  <video class="jquery-background-video" autoplay muted loop poster="">
    <source src="" type="video/mp4">
    <source src="" type="video/webm">
    <source src="" type="video/ogg">
	  <div class="video-overlay"></div>
  	<div class="page-width">
		    <div class="video-hero--content">
			      <h2>Background Video Demo</h2>
			      <p>Full width video hero</p>
<!-- End video hero -->

<div id="content">
	  <div class="page-width">
    		<h3>Easy Background Videos</h3>
		    <p>This page uses the <a href="" target="_blank">jQuery Background Video</a> plugin along with some simple html and css to generate this background video.</p>
		    <p>The video overlay pattern is available at <a href="" target="_blank"></a></p>
              /* Settings - feel free to play with these */
$overlay_opacity: 0.3; // 0-1
$overlay_pattern: ''; // Grab the url of a png from here -

@import url(,700);

 * This part should be set separately for each video
 * if there are multiple videos in your site.
 * I.e. '.demo-video-wrapper' is the name of this particular video
.demo-video-wrapper {
	background-image: url(;

/* Video overlay and content */
.video-overlay {
	position: absolute;
	top: 0;
	left: 0;
	bottom: 0;
	right: 0;
	pointer-events: none; /* Allows right click menu on the video */
	background: url($overlay_pattern) left top repeat;
  opacity: $overlay_opacity;
.video-hero--content {
	position: relative;
	text-align: center;
	color: #FFF;
  margin: 150px 0;
	text-shadow: 0 0 5px rgba(0,0,0,0.4);
.video-hero--content h2 {
	font-size: 34px;
	margin: 0 0 10px;
.video-hero--content p {
	font-size: 20px;
	margin: 0;

/* Other stuff */
body {
	font-family: 'Roboto', sans-serif;
	font-size: 16px;
	line-height: 1.4;
	color: #666;
a {
	text-decoration: none;
	color: #a46497;
.cf:after {
    content: " ";
    display: table;
.cf:after {
    clear: both;
.page-width {
	width: 92%;
	max-width: 960px;
	margin: 0 auto;
#header {
	background: #2c2d33;
	padding: 2em 0;
#header a {
	color: #FFF;
.title {
	display: block;
	font-weight: bold;
	font-size: 18px;
.subtitle {
	display: block;
	font-weight: normal;
	font-size: 15px;
	color: #959699;
a:hover .subtitle {
	color: #FFF;
#site-title {
	float: left;
	margin: 0;
#content {
	padding: 40px 0;

/* CSS from jQuery Background Video plugin */
 * Set default positioning as a fallback for if the plugin fails
.jquery-background-video-wrapper {
	position: relative;
	overflow: hidden;
	background-position: center center;
	background-repeat: no-repeat;
	-webkit-background-size: cover;
	   -moz-background-size: cover;
	    	background-size: cover;
.jquery-background-video {
	position: absolute;
	min-width: 100%;
	min-height: 100%;
	width: auto;
	height: auto;
	top: 50%;
	left: 50%;
	-o-object-fit: contain;
	   object-fit: contain;
	-webkit-transform: translate(-50%,-50%);
	   -moz-transform: translate(-50%,-50%);
	    -ms-transform: translate(-50%,-50%);
	     -o-transform: translate(-50%,-50%);
	    	transform: translate(-50%,-50%);
 * Fade in videos
 * Note the .js class - so non js users still
 * see the video
.js .jquery-background-video {
	opacity: 0;
	-webkit-transition: opacity 300ms linear;
			transition: opacity 300ms linear;
.js {
	opacity: 1;

 * Pause/play button
.jquery-background-video-pauseplay {
	position: absolute;
	background: transparent;
	border: none;
	box-shadow: none;
	width: 20px;
	height: 20px;
	top: 15px;
	right: 15px;
	padding: 0;
	cursor: pointer;
	outline: none !important;
.jquery-background-video-pauseplay span {
	display: none;
.jquery-background-video-pauseplay:before {
	content: "";
	position: absolute;
	left: 0;
	top: 0;
	-webkit-transition: all .3s ease;
			transition: all .3s ease;
} {
	border-top: 10px solid transparent;
	border-bottom: 10px solid transparent;
	border-left: 15px solid #FFF;
.jquery-background-video-pauseplay.pause:after {
	border-top: 10px solid #FFF;
	border-bottom: 10px solid #FFF;
	border-left: 5px solid #FFF;
.jquery-background-video-pauseplay.pause:after {
	left: 10px;
              /* Note Codepen is importing the jQuery Background Video plugin - */

$('.jquery-background-video').bgVideo({fadeIn: 2000});
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.