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="container">
<div>
<ul id="menu">
<li>
<input id="tab0" type="button" class="button" onclick="processTab(0);" value="Short Videos"></input>
</li>
<li>
<input id="tab1" type="button" class="button" onclick="processTab(1);" value="Assorted Bugs and Birds">
</li>
<li>
<input id="tab2" type="button" class="button" onclick="processTab(2);" value="Sea and Water">
</li>
<li><input id="tab3" type="button" class="button" onclick="processTab(3);" value="Sea Life"></li>
</ul>
</div>
<div class="myplayer">
<video-js id="myPlayerID"
data-account="1752604059001"
data-player="SJly4aArKZ"
data-embed="default"
data-application-id
controls
width="450"
height="253.13"></video-js>
<script src="https://players.brightcove.net/1752604059001/SJly4aArKZ_default/index.min.js"></script>
<ol class="vjs-playlist"></ol>
</div>
</div>
/* * The body style is just for the
* background color of the codepen.
* Do not include in your code.
*/
body {
background-color: #111;
color: #fff;
}
/*
* Styles essential to the sample
* are below
*/
/* Set the size of the container for the video player and tabbed playlist */
.container {
width: 1100px;
height: 400px;
}
/* Style the tabbed menu */
#menu {
float: right;
padding: 0;
padding-right: 85px;
margin: 0;
color: #fff;
font-family: arial, helvetica, sans-serif;
white-space: nowrap;
list-style-type: none;
}
#menu li {
display: inline;
}
#menu li input {
min-width: 50px;
height: 30px;
padding: 0.2em 1em;
background: #0000cc;
color: #fff;
text-decoration: none;
float: left;
border: 1px solid #fff;
border-top-left-radius: 1em;
border-top-right-radius: 1em;
}
.button {
background: #0000cc;
}
#menu li input:hover {
background: #08c;
color: #fff;
}
/* Set the size and location of the player */
.video-js {
width: 650px !important;
height: 360px !important;
float: left;
}
.myplayer {
clear: both;
width: 100%;
height: 100%;
position: relative;
}
/* Set the size of the tabbed playlist */
.vjs-playlist {
width: 365px;
height: 360px;
}
var myPlayer,
// Define an array of playlist Ids
playlistIds = ["4450721964001", "2805100167001", "2764931905001","1754200320001"],
// Get the playlist array length
playlistIdsLength = playlistIds.length,
// Get a reference to the playlist tabs
tabs = document.getElementsByClassName("button"),
currentTab,
currentTabName,
playlistNames = [];
videojs.getPlayer('myPlayerID').ready(function() {
// Get a reference to the player when it is ready
myPlayer = this;
// Load the first playlist tab into the player
processTab(0);
});
// +++ Set selected tab and load video +++
function processTab(index) {
// Reset the tabs so that none of them are selected/highlighted
resetTabs();
// Highlight the selected tab in the navigation
document.getElementById("tab" + index).setAttribute("style", "background:#08c;color: #00FFFF; border-bottom: 1px solid #00FFFF;");
// Load the selected tab's playlist into the player
loadPlaylist(playlistIds[index]);
};
// +++ Load selected playlist and first video +++
function loadPlaylist(currentId) {
// Get the playlist object for the currently selected tab
myPlayer.catalog.getPlaylist(currentId, function(error, playlist) {
// Load the playlist into the player
myPlayer.catalog.load(playlist);
// Load the first video in the playlist into the player
myPlayer.playlist.currentItem(0);
});
};
// +++ reset all tabs +++
function resetTabs() {
// Turn highlighting off for all of the tabs
var i,
iMax = tabs.length;
for (i = 0; i < iMax; i++) {
tabs[i].setAttribute("style", "background: #0000cc;color: #fff;")
}
}
Also see: Tab Triggers