JavaScript preprocessors can help make authoring JavaScript easier and more convenient. For instance, CoffeeScript can help prevent easy-to-make mistakes and offer a cleaner syntax and Babel can bring ECMAScript 6 features to browsers that only support ECMAScript 5.
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.
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 class="page-container">
<div class="video-container">
<video autoplay muted loop width="100%" height="100%" volume="0" canplay="false" role="img" aria-label="toy robot canon with motorized rotor">
<source src="http://techslides.com/demos/sample-videos/small.webm" type="video/webm">
<source src="http://techslides.com/demos/sample-videos/small.ogv" type="video/ogg">
<source src="http://techslides.com/demos/sample-videos/small.mp4" type="video/mp4">
<source src="http://techslides.com/demos/sample-videos/small.3gp" type="video/3gp">
<img src=" http://placehold.it/350x150" alt="test alt img" />
</video>
<button type="button" class="video-btn">
<span class="visuallyhidden">play or pause the video-image background. Video has no sound or narration</span>
<i aria-hidden="true" class="fa fa-pause"></i>
</button>
</div>
<div class="page-content">
<h1>Super Cool Motor Robots!</h1>
<p>Welcome to my site</p>
<ul>
<li>video element's img alt not read since it's a fallback only if video isn't supported </li>
<li>instead, aria-label + role="img" added</li>
<li>tested in VO & NVDA</li>
</ul>
<p>CAVEAT - this is a way to make a somewhat awkward pattern a little less awkward. Depending on the video, text might be a little hard to read. Also, site owners are the best judges of whether or not the video actually needs "alt" text, or if it's just decoration. In that case, aria-hidden may be the better approach.
</p>
<p>Having a video autoplay and loop may not be suitable for all audiences either, especially if the video has a lot going on visually and can be distracting.</p>
<p>For more background, read Emma Sax's<a href="http://www.punkchip.com/accessible-html-video-as-a-background"> article about accessible background videos</a></p>
</div>
</div>
/* font awesome added for icon, this can be done in any way */
/* maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css */
/*page container*/
.page-container {
position: relative;
min-height: 800px;
}
/*video background*/
video {
position: absolute;
top: 0px;
left: 0px;
right: 0;
bottom: 0;
min-width: 100%;
min-height: 100%;
z-index: -1000;
overflow: hidden;
}
/*video overlay to make text a litle less crappy*/
.video-container:after {
display: block;
z-index: 100;
content: "";
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
background: rgba(0,0,0,0.5);
}
/* play/pause button styles */
.visuallyhidden {
border: 0;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
.video-btn {
border: none;
background: none;
color: #fff;
position: absolute;
display: block;
font-size: 60px;
z-index: 101;
opacity: 0.5;
bottom: 10%;
right: 10%;
}
.video-btn:hover,
.video-btn:focus {
opacity: 1;
}
.is-paused .video-btn i:before {
content: "\f04b";
}
/*page styles*/
body {
font-family: "Helvetica", Arial, sans-serif;
background: #000;
color: #fff;
}
.page-content {
margin: 0 auto;
padding: 40px;
position: relative;
z-index: 100;
max-width: 1410px;
}
h1 {
color: #fff;
margin: 100px 0 15px;
font-weight: bold;
display: inline-block;
font-size: 30px;
}
ul {
margin-bottom: 20px;
}
ul, li {
list-style: disc;
list-style-position: inside;
}
p {
max-width: 600px;
line-height: 1.4;
color: #ddd;
}
a {
color: inherit;
}
var $videoTrigger = $(".video-btn");
var $videoContainer = $(".video-container");
$videoTrigger.on("click", function(evt) {
if ($videoContainer.hasClass("is-paused")) {
$videoContainer
.removeClass("is-paused")
.find("video").get(0).play();
}
else {
$videoContainer
.addClass("is-paused")
.find("video").get(0).pause();
}
});
/*
$('#play-pause-button').click(function () {
if ($("#media-video").get(0).paused) {
$("#media-video").get(0).play();
} else {
$("#media-video").get(0).pause();
}
});
}*/
Also see: Tab Triggers