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.
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#vtab-example-navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div class="navbar-brand">Vertical Bootstrap Tabs</div>
</div>
<div class="collapse navbar-collapse" id="vtab-example-navbar-collapse">
<ul class="nav navbar-nav">
<li>
<a href="#" data-target="right">Right Side Tabs</a>
</li>
<li>
<a href="#left" data-target="left">Left Side Tabs</a>
</li>
</ul>
</div>
<!-- /.navbar-collapse --> </div>
</nav>
<div class="container-fluid">
<div class="tabbable tabs-vertical tabs-right">
<ul id="myTab" class="nav nav-tabs">
<li class="active">
<a href="#dash" data-toggle="tab">Dashboard</a>
</li>
<li>
<a href="#blog" data-toggle="tab">Blog</a>
</li>
<li>
<a href="#contact" data-toggle="tab">Contact</a>
</li>
</ul>
<div id="myTabContent" class="tab-content">
<div class="tab-pane fade in active" id="dash">
<h1 class="page-header">Dashboard</h1>
<div class="row placeholders">
<div class="col-xs-6 col-sm-3 placeholder">
<img class="img-responsive" alt="200x200" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMDAiIGhlaWdodD0iMjAwIj48cmVjdCB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCIgZmlsbD0iIzBEOEZEQiI+PC9yZWN0Pjx0ZXh0IHRleHQtYW5jaG9yPSJtaWRkbGUiIHg9IjEwMCIgeT0iMTAwIiBzdHlsZT0iZmlsbDojZmZmO2ZvbnQtd2VpZ2h0OmJvbGQ7Zm9udC1zaXplOjEzcHg7Zm9udC1mYW1pbHk6QXJpYWwsSGVsdmV0aWNhLHNhbnMtc2VyaWY7ZG9taW5hbnQtYmFzZWxpbmU6Y2VudHJhbCI+MjAweDIwMDwvdGV4dD48L3N2Zz4=">
<h4>Label</h4>
<span class="text-muted">Something else</span>
</div>
<div class="col-xs-6 col-sm-3 placeholder">
<img class="img-responsive" alt="200x200" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMDAiIGhlaWdodD0iMjAwIj48cmVjdCB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCIgZmlsbD0iIzM5REJBQyI+PC9yZWN0Pjx0ZXh0IHRleHQtYW5jaG9yPSJtaWRkbGUiIHg9IjEwMCIgeT0iMTAwIiBzdHlsZT0iZmlsbDojMUUyOTJDO2ZvbnQtd2VpZ2h0OmJvbGQ7Zm9udC1zaXplOjEzcHg7Zm9udC1mYW1pbHk6QXJpYWwsSGVsdmV0aWNhLHNhbnMtc2VyaWY7ZG9taW5hbnQtYmFzZWxpbmU6Y2VudHJhbCI+MjAweDIwMDwvdGV4dD48L3N2Zz4=">
<h4>Label</h4>
<span class="text-muted">Something else</span>
</div>
<div class="col-xs-6 col-sm-3 placeholder">
<img class="img-responsive" alt="200x200" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMDAiIGhlaWdodD0iMjAwIj48cmVjdCB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCIgZmlsbD0iIzBEOEZEQiI+PC9yZWN0Pjx0ZXh0IHRleHQtYW5jaG9yPSJtaWRkbGUiIHg9IjEwMCIgeT0iMTAwIiBzdHlsZT0iZmlsbDojZmZmO2ZvbnQtd2VpZ2h0OmJvbGQ7Zm9udC1zaXplOjEzcHg7Zm9udC1mYW1pbHk6QXJpYWwsSGVsdmV0aWNhLHNhbnMtc2VyaWY7ZG9taW5hbnQtYmFzZWxpbmU6Y2VudHJhbCI+MjAweDIwMDwvdGV4dD48L3N2Zz4=">
<h4>Label</h4>
<span class="text-muted">Something else</span>
</div>
<div class="col-xs-6 col-sm-3 placeholder">
<img class="img-responsive" alt="200x200" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMDAiIGhlaWdodD0iMjAwIj48cmVjdCB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCIgZmlsbD0iIzM5REJBQyI+PC9yZWN0Pjx0ZXh0IHRleHQtYW5jaG9yPSJtaWRkbGUiIHg9IjEwMCIgeT0iMTAwIiBzdHlsZT0iZmlsbDojMUUyOTJDO2ZvbnQtd2VpZ2h0OmJvbGQ7Zm9udC1zaXplOjEzcHg7Zm9udC1mYW1pbHk6QXJpYWwsSGVsdmV0aWNhLHNhbnMtc2VyaWY7ZG9taW5hbnQtYmFzZWxpbmU6Y2VudHJhbCI+MjAweDIwMDwvdGV4dD48L3N2Zz4=">
<h4>Label</h4>
<span class="text-muted">Something else</span>
</div>
</div>
<h2 class="sub-header">Section title</h2>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>#</th>
<th>Header</th>
<th>Header</th>
<th>Header</th>
<th>Header</th>
</tr>
</thead>
<tbody>
<tr>
<td>1,001</td>
<td>Lorem</td>
<td>ipsum</td>
<td>dolor</td>
<td>sit</td>
</tr>
<tr>
<td>1,002</td>
<td>amet</td>
<td>consectetur</td>
<td>adipiscing</td>
<td>elit</td>
</tr>
<tr>
<td>1,003</td>
<td>Integer</td>
<td>nec</td>
<td>odio</td>
<td>Praesent</td>
</tr>
<tr>
<td>1,003</td>
<td>libero</td>
<td>Sed</td>
<td>cursus</td>
<td>ante</td>
</tr>
<tr>
<td>1,004</td>
<td>dapibus</td>
<td>diam</td>
<td>Sed</td>
<td>nisi</td>
</tr>
<tr>
<td>1,005</td>
<td>Nulla</td>
<td>quis</td>
<td>sem</td>
<td>at</td>
</tr>
<tr>
<td>1,006</td>
<td>nibh</td>
<td>elementum</td>
<td>imperdiet</td>
<td>Duis</td>
</tr>
<tr>
<td>1,007</td>
<td>sagittis</td>
<td>ipsum</td>
<td>Praesent</td>
<td>mauris</td>
</tr>
<tr>
<td>1,008</td>
<td>Fusce</td>
<td>nec</td>
<td>tellus</td>
<td>sed</td>
</tr>
<tr>
<td>1,009</td>
<td>augue</td>
<td>semper</td>
<td>porta</td>
<td>Mauris</td>
</tr>
<tr>
<td>1,010</td>
<td>massa</td>
<td>Vestibulum</td>
<td>lacinia</td>
<td>arcu</td>
</tr>
<tr>
<td>1,011</td>
<td>eget</td>
<td>nulla</td>
<td>Class</td>
<td>aptent</td>
</tr>
<tr>
<td>1,012</td>
<td>taciti</td>
<td>sociosqu</td>
<td>ad</td>
<td>litora</td>
</tr>
<tr>
<td>1,013</td>
<td>torquent</td>
<td>per</td>
<td>conubia</td>
<td>nostra</td>
</tr>
<tr>
<td>1,014</td>
<td>per</td>
<td>inceptos</td>
<td>himenaeos</td>
<td>Curabitur</td>
</tr>
<tr>
<td>1,015</td>
<td>sodales</td>
<td>ligula</td>
<td>in</td>
<td>libero</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="tab-pane fade" id="blog">
<h1 class="page-header">Blog</h1>
<p>
This blog post shows a few different types of content that's supported and styled with Bootstrap. Basic typography, images, and code are all supported.
</p>
<hr>
<p>
Cum sociis natoque penatibus et magnis
<a href="#">dis parturient montes</a>
, nascetur ridiculus mus. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Sed posuere consectetur est at lobortis. Cras mattis consectetur purus sit amet fermentum.
</p>
<blockquote>
<p>
Curabitur blandit tempus porttitor. <strong>Nullam quis risus eget urna mollis</strong>
ornare vel eu leo. Nullam id dolor id nibh ultricies vehicula ut id elit.
</p>
</blockquote>
<p>
Etiam porta <em>sem malesuada magna</em>
mollis euismod. Cras mattis consectetur purus sit amet fermentum. Aenean lacinia bibendum nulla sed consectetur.
</p>
<h2>Heading</h2>
<p>
Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.
</p>
<h3>Sub-heading</h3>
<p>
Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
</p>
<pre><code>Example code block</code></pre>
<p>
Aenean lacinia bibendum nulla sed consectetur. Etiam porta sem malesuada magna mollis euismod. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa.
</p>
<h3>Sub-heading</h3>
<p>
Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aenean lacinia bibendum nulla sed consectetur. Etiam porta sem malesuada magna mollis euismod. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.
</p>
<ul>
<li>
Praesent commodo cursus magna, vel scelerisque nisl consectetur et.
</li>
<li>Donec id elit non mi porta gravida at eget metus.</li>
<li>Nulla vitae elit libero, a pharetra augue.</li>
</ul>
<p>
Donec ullamcorper nulla non metus auctor fringilla. Nulla vitae elit libero, a pharetra augue.
</p>
<ol>
<li>Vestibulum id ligula porta felis euismod semper.</li>
<li>
Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
</li>
<li>
Maecenas sed diam eget risus varius blandit sit amet non magna.
</li>
</ol>
<p>
Cras mattis consectetur purus sit amet fermentum. Sed posuere consectetur est at lobortis.
</p>
</div>
<div class="tab-pane fade" id="contact">
<h1 class="page-header">Contact</h1>
<div class="row">
<div class="col-md-8">
<div class="well well-sm">
<form>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" id="name" placeholder="Enter name" required="required" />
</div>
<div class="form-group">
<label for="email">Email Address</label>
<div class="input-group">
<span class="input-group-addon">
<span class="glyphicon glyphicon-envelope"></span>
</span>
<input type="email" class="form-control" id="email" placeholder="Enter email" required="required" />
</div>
</div>
<div class="form-group">
<label for="subject">Subject</label>
<select id="subject" name="subject" class="form-control" required="required">
<option value="na" selected="">Choose One:</option>
<option value="service">General Customer Service</option>
<option value="suggestions">Suggestions</option>
<option value="product">Product Support</option>
</select>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="name">Message</label>
<textarea name="message" id="message" class="form-control" rows="9" cols="25" required="required"
placeholder="Message"></textarea>
</div>
</div>
<div class="col-md-12">
<button type="submit" class="btn btn-primary pull-right" id="btnContactUs">Send Message</button>
</div>
</div>
</form>
</div>
</div>
<div class="col-md-4">
<form>
<legend>
<span class="glyphicon glyphicon-globe"></span>
Our office
</legend>
<address> <strong>Twitter, Inc.</strong>
<br>
795 Folsom Ave, Suite 600
<br>
San Francisco, CA 94107
<br> <abbr title="Phone">P:</abbr>
(123) 456-7890
</address>
<address>
<strong>Full Name</strong>
<br>
<a href="mailto:#">first.last@example.com</a>
</address>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
@import "compass/css3";
$borderRadiusBase: 4px;
$navTabVerticalMinWidth: 74px;
$navTabSpacing: 3px;
$navTabContentSpacing: 20px;
$verticalTabHeight: 42px;
$navTabBdWidth: 1px;
$navTabBdColor: #ddd;
$navLinkBgActive: #fff;
$navTabBgActive: $navLinkBgActive;
$navTabBgHover: #eee;
@mixin clearfix {
*zoom: 1;
&:before,
&:after {
display: table;
content: "";
}
&:after {
clear: both;
}
}
.tabbable {
@include clearfix;
}
.tab-content {
overflow: auto; // prevent content from running below tabs
}
// Remove border on bottom, left, right
.tabs-right > .nav-tabs,
.tabs-left > .nav-tabs {
border-bottom: 0;
}
// LEFT & RIGHT
// ------------
// Common styles
.tabs-left,
.tabs-right {
.nav-tabs > li {
float: none;
> a {
min-width: $navTabVerticalMinWidth;
margin-right: 0;
margin-bottom: $navTabSpacing;
}
}
}
// Tabs on the left
.tabs-left > .nav-tabs {
float: left;
margin-right: $navTabContentSpacing - $navTabBdWidth;
border-right: $navTabBdWidth solid $navTabBdColor;
> li {
> a {
margin-right: -$navTabBdWidth;
@include border-radius($borderRadiusBase 0 0 $borderRadiusBase);
&:hover,
&:focus {
border-color: $navTabBgHover $navTabBdColor $navTabBgHover $navTabBgHover;
}
}
&.active {
> a {
&,
&:hover,
&:focus {
border-color: $navTabBdColor transparent $navTabBdColor $navTabBdColor;
*border-right-color: $navTabBgActive;
}
}
}
}
}
// Tabs on the right
.tabs-right > .nav-tabs {
float: right;
margin-left: $navTabContentSpacing - $navTabBdWidth;
border-left: $navTabBdWidth solid $navTabBdColor;
> li {
> a {
margin-left: -$navTabBdWidth;
@include border-radius(0 $borderRadiusBase $borderRadiusBase 0);
&:hover,
&:focus {
border-color: $navTabBgHover $navTabBgHover $navTabBgHover $navTabBdColor;
}
}
&.active {
> a {
&,
&:hover,
&:focus {
border-color: $navTabBdColor $navTabBdColor $navTabBdColor transparent;
*border-left-color: $navTabBgActive;
}
}
}
}
}
// VERTICAL VARIATION
// -------------------------
.tabs-vertical {
position: relative;
> .nav-tabs {
position: absolute;
top: $navTabContentSpacing;
display: block;
width: auto;
height: $verticalTabHeight;
margin: 0;
white-space: nowrap;
border: 0 none;
@include transform-origin(0, 0);
@include rotate(90deg);
@include box-sizing(border-box);
> li {
position: relative;
display: inline-block;
> a {
min-width: 0;
margin: 0;
}
&.active {
z-index: 1; // keep above adjacent tabs
}
}
}
&.tabs-left {
> .nav-tabs {
left: $verticalTabHeight + $navTabBdWidth; // must use this because of left margin on tab-content
border-top: $navTabBdWidth solid $navTabBdColor;
> li {
height: $verticalTabHeight + $navTabBdWidth;
top: -$navTabBdWidth;
> a {
@include border-radius(0 0 $borderRadiusBase $borderRadiusBase);
&:hover,
&:focus {
border-color: $navTabBdColor $navTabBgHover $navTabBgHover $navTabBgHover;
}
}
&.active {
> a {
&,
&:hover,
&:focus {
background-color: $navLinkBgActive; // overlap border of tab-content
border-color: transparent $navTabBdColor $navTabBdColor $navTabBdColor;
*border-top-color: $navTabBgActive;
}
}
}
}
}
.tab-content {
margin-left: $verticalTabHeight;
border-left: $navTabBdWidth solid $navTabBdColor;
}
}
&.tabs-right {
> .nav-tabs {
left: 100%;
margin-left: -$navTabBdWidth;
border-bottom: $navTabBdWidth solid $navTabBdColor;
> li {
> a {
@include border-radius($borderRadiusBase $borderRadiusBase 0 0);
&:hover,
&:focus {
border-color: $navTabBgHover $navTabBgHover $navTabBdColor $navTabBgHover;
}
}
&.active {
> a {
&,
&:hover,
&:focus {
background-color: $navLinkBgActive; // overlap border of tab-content
border-color: $navTabBdColor $navTabBdColor transparent $navTabBdColor;
*border-bottom-color: $navTabBgActive;
}
}
}
}
}
.tab-content {
margin-right: $verticalTabHeight;
border-right: $navTabBdWidth solid $navTabBdColor;
}
}
}
// STUFF FOR THIS DEMO ONLY
// -------------------------
body {
padding-top: 50px; // clear the fixed-top navbar!
}
.tab-content {
.tabs-left & {
padding-left: $navTabContentSpacing;
}
.tabs-right & {
padding-right: $navTabContentSpacing;
}
}
.sub-header {
padding-bottom: 10px;
border-bottom: 1px solid #eee;
}
.page-header {
margin-top: 10px;
}
.placeholders {
margin-bottom: 30px;
text-align: center;
}
.placeholders h4 {
margin-bottom: 0;
}
.placeholder {
margin-bottom: 20px;
}
.placeholder img {
display: inline-block;
border-radius: 50%;
}
/* FOR DEMO ONLY (NOT NECESSARY TO IMPLEMENT VERTICAL TABS) */
var $tabSideNav = $('.navbar .navbar-nav');
var $tabSideToggles = $('a', $tabSideNav);
var $tabTypeContainer = $('.tabbable');
var $tabContentContainer = $('.tab-content', $tabTypeContainer);
if ($tabTypeContainer.hasClass('tabs-left')) {
$tabSideToggles.filter('[data-target=left]').parent('li').addClass('active');
} else {
$tabSideToggles.filter('[data-target=right]').parent('li').addClass('active');
}
$tabSideToggles.on('click', function (e) {
e && e.preventDefault();
$tabSideNav.find('li').removeClass('active');
$(this).parent('li').addClass('active');
var target = $(this).attr('data-target');
if (target === 'right') {
if ($tabTypeContainer.hasClass('tabs-left')) {
$tabTypeContainer
.removeClass('tabs-left')
.addClass('tabs-right');
}
}
if (target === 'left') {
if ($tabTypeContainer.hasClass('tabs-right')) {
$tabTypeContainer
.removeClass('tabs-right')
.addClass('tabs-left');
}
}
});
Also see: Tab Triggers