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.
.tabs
.tabs-header
.border
ul
li.active: a(href='#tab-1'
tab-id='1'
ripple
ripple-color='#FFF') Tab 1
li: a(href='#tab-2'
tab-id='2'
ripple
ripple-color='#FFF') Tab 2
li: a(href='#tab-3'
tab-id='3'
ripple
ripple-color='#FFF') Tab 3
li: a(href='#tab-4'
tab-id='4'
ripple
ripple-color='#FFF') Tab 4
li: a(href='#tab-5'
tab-id='5'
ripple
ripple-color='#FFF') Tab 5
nav.tabs-nav
i.material-icons#prev(ripple
ripple-color='#FFF') 
i.material-icons#next(ripple
ripple-color='#FFF') 
.tabs-content
.tab.active(tab-id='1')
| 1. Donec ullamcorper nulla non metus auctor fringilla. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Curabitur blandit tempus porttitor. Ellentesque ornare sem lacinia quam venenatis vestibulum. Curabitur blandit tempus porttitor. Donec ullamcorper nulla non metus auctor fringilla. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Curabitur blandit tempus porttitor. Donec ullamcorper nulla non metus auctor fringilla. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Curabitur blandit tempus porttitor.
.tab(tab-id='2')
| 2. Donec ullamcorper nulla non metus auctor fringilla. Aenean eu leo quam.
.tab(tab-id='3')
| 3. Donec ullamcorper nulla non metus auctor fringilla. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Curabitur blandit tempus porttitor.
.tab(tab-id='4')
| 4. Donec ullamcorper nulla non metus auctor fringilla. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Curabitur blandit tempus porttitor. Maecenas faucibus mollis interdum. Donec ullamcorper nulla non metus auctor fringilla. Aenean lacinia bibendum nulla sed consectetur. Aenean lacinia bibendum nulla sed consectetur.
.tab(tab-id='5')
| 5. Donec ullamcorper nulla non metus auctor fringilla. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Curabitur blandit tempus porttitor.Cras mattis consectetur purus sit amet fermentum. Maecenas sed diam eget risus varius blandit sit amet non magna. Nullam quis risus eget urna mollis ornare vel eu leo. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Maecenas sed diam eget risus varius blandit sit amet non magna. Maecenas sed diam eget risus varius blandit sit amet non magna. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Vestibulum id ligula porta felis euismod semper. Aenean lacinia bibendum nulla sed consectetur. Donec id elit non mi porta gravida at eget metus. Donec id elit non mi porta gravida at eget metus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Maecenas faucibus mollis interdum. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Aenean lacinia bibendum nulla sed consectetur. Maecenas faucibus mollis interdum. Donec ullamcorper nulla non metus auctor fringilla. Aenean lacinia bibendum nulla sed consectetur. Aenean lacinia bibendum nulla sed consectetur.
.pen-footer
a(href='https://www.behance.net/gallery/31103291/Tabs-UI-Library'
target='_blank')
i.material-icons arrow_backward
| View on Behance
a(href='https://github.com/andyhqtran/UI-Library/tree/master/Tabs'
target='_blank')
| View on Github
i.material-icons arrow_forward
// Font Family
$body-font: "Roboto";
// Font Weights
$thin: 100;
$light: 300;
$regular: 400;
$semibold: 500;
$bold: 700;
$ultra: 800;
// Base Font
$base-font-family: $body-font, sans-serif;
$base-font-size: 14px;
$base-font-weight: $regular;
$base-line-height: 1.6em;
// Colors
$black: #000000;
$dark-gray: rgba($black, 0.8);
$gray: rgba($black, 0.6);
$light-gray: rgba($black, 0.4);
$lighter-gray: rgba($black, 0.2);
$white: #FFFFFF;
$accent: #4285F4;
$primary: #2F313A;
$secondary: #F4B142;
// Form Settings
$max-width: 600px;
$max-height: 400px;
$gutters: 24px;
html {
width: 100%;
height: 100%;
}
body {
background: linear-gradient(45deg, rgba(66, 183, 245,0.8) 0%,rgba(66, 245, 189,0.4) 100%);
color: $gray;
font-family: $base-font-family;
font-size: $base-font-size;
line-height: $base-line-height;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
// Ripple
[ripple] {
z-index: 1;
position: relative;
overflow: hidden;
.ripple {
position: absolute;
background: $white;
width: 12px;
height: 12px;
border-radius: 100%;
animation: ripple 1.6s;
}
}
@keyframes ripple {
0% {
transform: scale(1);
opacity: 0.2;
}
100% {
transform: scale(40);
opacity: 0;
}
}
.tabs {
z-index: 15px;
position: relative;
background: $white;
width: $max-width;
border-radius: 4px;
box-shadow: 0 0 30px rgba($black, 0.1);
box-sizing: border-box;
margin: 100px auto 10px;
overflow: hidden;
// Tabs Header
&-header {
position: relative;
background: $accent;
overflow: hidden;
// Border
.border {
position: absolute;
bottom: 0;
left: 0;
background: $secondary;
width: auto;
height: 2px;
transition: 0.3s ease;
}
// List
ul {
display: flex;
flex-direction: row;
flex-wrap: wrap;
width: calc(100% - 68px);
}
// List Item
li {
transition: 0.3s ease;
}
// Anchor
a {
z-index: 1;
display: block;
box-sizing: border-box;
padding: 15px 20px;
color: $white;
font-weight: $semibold;
text-decoration: none;
text-transform: uppercase;
}
}
// Tabs Nav
&-nav {
position: absolute;
top: 0;
right: 0;
background: $accent;
display: flex;
align-items: center;
height: 100%;
padding: 0 10px;
color: $white;
user-select: none;
// Fade
&:before {
content: '';
z-index: 1;
position: absolute;
top: 0;
left: 0;
height: 100%;
box-shadow: 0 0 20px 10px $accent;
}
// Arrows
i {
border-radius: 100%;
cursor: pointer;
}
}
// Tabs Content
&-content {
position: relative;
padding: 15px 20px;
transition: 0.3s ease;
overflow: hidden;
// Blurred Text Effect
&:after {
content: '';
position: absolute;
bottom: -1px;
left: 0;
display: block;
width: 100%;
height: 1px;
box-shadow: 0 0 20px 10px $white;
}
// Tab
.tab {
display: none;
// Active
&.active {
display: block;
}
}
}
}
// Pen Footer
.pen-footer {
display: flex;
flex-direction: row;
justify-content: space-between;
width: $max-width;
margin: 20px auto 100px;
a {
color: $white;
font-size: 12px;
text-decoration: none;
text-shadow: 1px 2px 0 rgba($black, .1);
.material-icons {
width: 12px;
margin: 0 5px;
vertical-align: middle;
font-size: 12px;
}
}
}
.cp-fab {
background: $white !important;
color: $accent !important;
}
$(document).ready(function () {
// Intial Border Position
var activePos = $('.tabs-header .active').position();
// Change Position
function changePos() {
// Update Position
activePos = $('.tabs-header .active').position();
// Change Position & Width
$('.border').stop().css({
left: activePos.left,
width: $('.tabs-header .active').width()
});
}
changePos();
// Intial Tab Height
var tabHeight = $('.tab.active').height();
// Animate Tab Height
function animateTabHeight() {
// Update Tab Height
tabHeight = $('.tab.active').height();
// Animate Height
$('.tabs-content').stop().css({
height: tabHeight + 'px'
});
}
animateTabHeight();
// Change Tab
function changeTab() {
var getTabId = $('.tabs-header .active a').attr('tab-id');
// Remove Active State
$('.tab').stop().fadeOut(300, function () {
// Remove Class
$(this).removeClass('active');
}).hide();
$('.tab[tab-id=' + getTabId + ']').stop().fadeIn(300, function () {
// Add Class
$(this).addClass('active');
// Animate Height
animateTabHeight();
});
}
// Tabs
$('.tabs-header a').on('click', function (e) {
e.preventDefault();
// Tab Id
var tabId = $(this).attr('tab-id');
// Remove Active State
$('.tabs-header a').stop().parent().removeClass('active');
// Add Active State
$(this).stop().parent().addClass('active');
changePos();
// Update Current Itm
tabCurrentItem = tabItems.filter('.active');
// Remove Active State
$('.tab').stop().fadeOut(300, function () {
// Remove Class
$(this).removeClass('active');
}).hide();
// Add Active State
$('.tab[tab-id="' + tabId + '"]').stop().fadeIn(300, function () {
// Add Class
$(this).addClass('active');
// Animate Height
animateTabHeight();
});
});
// Tab Items
var tabItems = $('.tabs-header ul li');
// Tab Current Item
var tabCurrentItem = tabItems.filter('.active');
// Next Button
$('#next').on('click', function (e) {
e.preventDefault();
var nextItem = tabCurrentItem.next();
tabCurrentItem.removeClass('active');
if (nextItem.length) {
tabCurrentItem = nextItem.addClass('active');
} else {
tabCurrentItem = tabItems.first().addClass('active');
}
changePos();
changeTab();
});
// Prev Button
$('#prev').on('click', function (e) {
e.preventDefault();
var prevItem = tabCurrentItem.prev();
tabCurrentItem.removeClass('active');
if (prevItem.length) {
tabCurrentItem = prevItem.addClass('active');
} else {
tabCurrentItem = tabItems.last().addClass('active');
}
changePos();
changeTab();
});
// Ripple
$('[ripple]').on('click', function (e) {
var rippleDiv = $('<div class="ripple" />'),
rippleOffset = $(this).offset(),
rippleY = e.pageY - rippleOffset.top,
rippleX = e.pageX - rippleOffset.left,
ripple = $('.ripple');
rippleDiv.css({
top: rippleY - (ripple.height() / 2),
left: rippleX - (ripple.width() / 2),
background: $(this).attr("ripple-color")
}).appendTo($(this));
window.setTimeout(function () {
rippleDiv.remove();
}, 1500);
});
});
Also see: Tab Triggers