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.
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<link href="https://fonts.googleapis.com/css?family=Josefin+Sans" rel="stylesheet">
<script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://use.fontawesome.com/aa95071b26.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div id="body">
<div class="out-wrap">
<ul id="tabs" class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a href="#home" aria-controls="home" role="tab" data-toggle="tab">Home</a></li>
<li role="presentation"><a href="#profile" aria-controls="profile" role="tab" data-toggle="tab">Profile</a></li>
<li role="presentation"><a href="#messages" aria-controls="messages" role="tab" data-toggle="tab">Messages</a></li>
<li role="presentation"><a href="#settings" aria-controls="settings" role="tab" data-toggle="tab">Settings</a></li>
<li role="presentation"><a href="#about" aria-controls="about" role="tab" data-toggle="tab">About</a></li>
<li role="presentation"><a href="#foryou" aria-controls="foryou" role="tab" data-toggle="tab">For You</a></li>
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="home">Lorem ipsum dolor sit amet, id pede etiam, ultricies nunc torquent luctus, vel vivamus, pede est interdum lectus ligula sit, vel egestas volutpat aptent aliquam. Sed luctus egestas. Placerat turpis rutrum maecenas, sodales viverra ab, purus consectetuer ut tincidunt lobortis massa. Sit vel, duis mi metus et felis egestas, dis integer vitae, feugiat consectetuer elit, natoque lacus leo volutpat donec quam bibendum. Felis mauris.</div>
<div role="tabpanel" class="tab-pane" id="profile">Nulla ipsum elit, eleifend sed. Fermentum sit, consequat commodo vel massa integer in wisi, quam libero, mollis tortor dapibus porttitor, euismod nonummy duis et rutrum et nibh. Ullamcorper in at, justo eu amet id sed, vel amet ut et velit velit, suscipit ultricies. Lectus quis proin sodales. Eu donec etiam vestibulum id lectus nascetur, mauris amet pellentesque posuere sit vitae, dolor consectetur nec varius, vitae sed quis dolor commodo lacus. Rhoncus platea risus omnis aenean, rhoncus nibh eget turpis eros enim, magna vestibulum enim minima habitant malesuada porttitor, nibh donec magna lorem nunc vitae.</div>
<div role="tabpanel" class="tab-pane" id="messages">Diam vulputate interdum ac et eget, et interdum proin, nec aliquet a. Vitae lobortis elit morbi, pede mi nullam lacus magna consectetuer lobortis, hendrerit amet nulla et rutrum, et per a in, integer lectus nunc ac dignissim sit. Vestibulum dignissim placerat, sed arcu vitae, quis hac ultrices at, fringilla nullam ut. Tempor cursus quam sit, tempus iaculis enim dolor. Platea pede nullam quis, urna aut tellus est, nibh feugiat tristique metus nec viverra vestibulum, nulla et ut mauris dui. Neque tortor tristique, volutpat velit et. Ipsum sit tellus eos, morbi scelerisque suspendisse, luctus in animi nam diam, fusce metus morbi. Pretium lacus a phasellus, donec pede duis eget vestibulum in. Vivamus ac nullam feugiat quaerat pharetra.</div>
<div role="tabpanel" class="tab-pane" id="settings">Elit in gravida a sem pellentesque sodales, cursus turpis turpis, vitae nec urna. Feugiat id ultricies interdum metus, felis wisi, ornare wisi orci proin amet lacinia adipiscing. Sollicitudin donec quis libero sit, euismod lorem ornare ante lacus hendrerit vitae, parturient aliquet pellentesque quam eu, eu hendrerit rhoncus odio, urna etiam ut purus. Nonummy elit ultricies saepe adipiscing nam quam, magna dis, molestie risus metus pretium nunc, et cras tempus dignissim duis arcu nec, mauris laboriosam suspendisse. In mi vivamus, tempor sit sed congue. A vehicula vel nulla hendrerit bibendum, metus pretium curabitur elementum at, pede congue sodales risus rutrum sed, vel imperdiet suspendisse recusandae conubia.</div>
<div role="tabpanel" class="tab-pane" id="about">itae, parturient aliquet pellentesque quam eu, eu hendrerit rhoncus odio, urna etiam ut purus. Nonummy elit ultricies saepe adipiscing nam quam, magna dis, molestie risus metus pretium nunc, et cras tempus dignissim duis arcu nec, mauris laboriosam suspendisse. In mi vivamus, tempor sit sed congue. A vehicula vel nulla hendrerit bibendu.</div>
<div role="tabpanel" class="tab-pane" id="foryou">Terdum proin, nec aliquet a. Vitae lobortis elit morbi, pede mi nullam lacus magna consectetuer lobortis, hendrerit amet nulla et rutrum, et per a in, integer lectus nunc ac dignissim sit. Vestibulum dignissim placerat, sed arcu vitae, quis hac ultrices at, fringilla nullam ut. Tempor cursus quam sit, tempus iaculis enim dolor. Platea pede nullam quis, urna aut tellus est, nibh feugiat tristique metus nec viverra vestibulum, nulla et ut mauris dui. Neque tortor tristique, volutpat velit et. Ipsum sit tellus eos, morbi scelerisque suspendisse, luctus in animi nam diam, fusce metus morbi. Pretium lacus a phasellus, donec pede duis eget vestibulum ac.</div>
</div>
</div>
</div>
// Extra small screen / phone
$screen-xs-min: 480px;
// Small screen / tablet
$screen-sm-min: 768px;
// Medium screen / desktop
$screen-md-min: 992px;
// Large screen / wide desktop
$screen-lg-min: 1200px;
// So media queries don't overlap when required, provide a maximum
$screen-xs-max: ($screen-sm-min - 1);
$screen-sm-max: ($screen-md-min - 1);
$screen-md-max: ($screen-lg-min - 1);
@mixin respondTo($media) {
@if $media == "xs" {
@media only screen and (max-width: $screen-xs-max) {
@content;
}
}
@else if $media == "sm" {
@media only screen and (max-width: $screen-sm-max) and (min-width: $screen-sm-min) {
@content;
}
}
@else if $media == "md" {
@media only screen and (max-width: $screen-md-max) and (min-width: $screen-md-min) {
@content;
}
}
@else if $media == "lg" {
@media only screen and (min-width: $screen-lg-min) {
@content;
}
}
}
@mixin respondToAbove($media) {
@if $media == "xs" {
@media only screen and (min-width: $screen-xs-max) {
@content;
}
}
@else if $media == "sm" {
@media only screen and (min-width: $screen-sm-min) {
@content;
}
}
@else if $media == "md" {
@media only screen and (min-width: $screen-md-min) {
@content;
}
}
@else if $media == "lg" {
@media only screen and (min-width: $screen-lg-min) {
@content;
}
}
}
@mixin respondToBelow($media) {
@if $media == "xs" {
@media only screen and (max-width: $screen-xs-max) {
@content;
}
}
@else if $media == "sm" {
@media only screen and (max-width: $screen-sm-max) {
@content;
}
}
@else if $media == "md" {
@media only screen and (max-width: $screen-md-max) {
@content;
}
}
@else if $media == "lg" {
@media only screen {
@content;
}
}
}
@mixin respondToTablet {
@media (min-width: $screen-sm-min) and (max-width: $screen-sm-max){
@content;
}
}
@mixin respondToSmall-n-Medium {
@media (min-width: $screen-sm-min) and (max-width: $screen-md-max){
@content;
}
}
@mixin respondToMobile() {
@include respondTo(xs){
@content
}
}
@mixin respondToDesktop() {
@include respondToAbove(md){
@content
}
}
@mixin close-icon{
font-size: 0 !important;
position: absolute;
height: 40px;
width: 40px;
right: 20px;
top: 20px;
font-size: 0px;
cursor: pointer;
z-index: 9;
border: 0;
background: transparent;
&:before,&:after{
content: '';
top: 0;
right: 0;
left: 0;
bottom: 0;
margin: auto;
position: absolute;
height: 2px;
background: #fff;
width: 50%;
transition: all .25s;
opacity: 0;
}
&:before{
transform: rotate(45deg);
opacity: 1;
}
&:after{
transform: rotate(-45deg);
opacity: 1;
}
}
@mixin radio-button{
display: none;
& + *{
position: relative;
padding-left: 30px;
margin-left: 10px;
&:before{
content: '';
width: 20px;
@include rounded_corners(50%);
height: 20px;
@include box-shadow(inset 0px 1px 5px rgba(0,0,0,0.5));
text-indent: 30px;
left: 0;
top: 0;
position: absolute;
cursor: pointer;
}
&:after {
content: '';
width: 20px;
height: 20px;
cursor: pointer;
position: absolute;
z-index: 1;
background: $dbc;
@include rounded_corners(50%);
@include transition(all .25s);
top: 0;
left: 0;
@include transform(scale(0));
}
}
&:checked + *:after {
@include transform(scale(.4));
@include transition(all .25s cubic-bezier(0.68,0.55,0.265,3));
}
}
@mixin check-box{
display: none;
& + *{
position: relative;
padding-left: 30px;
margin-left: 10px;
&:before{
content: '';
width: 18px;
height: 18px;
@include box-shadow(inset 0px 1px 5px rgba(0,0,0,0.5));
text-indent: 30px;
left: 0;
top: 0;
position: absolute;
cursor: pointer;
}
&:after {
content: '';
width: 25px;
height: 15px;
cursor: pointer;
position: absolute;
z-index: 1;
border: solid $solid-color;
border-width: 0 0 7px 7px;
top: 0;
left: -3px;
@include transform(rotate(0deg) scale(0));
@include transition(all .25s);
}
}
&:checked + *:after {
@include transform(rotate(-45deg) scale(0.4));
@include transition(all .25s cubic-bezier(0.68,0.55,0.265,3));
}
&:checked + *:before {
background: $dbc;
}
}
@mixin calwidth($val1, $val2){
width: calc(#{$val1} + #{$val2})
}
@mixin transition-hvr($t-duration, $t-type){
position: relative;
transition: all $t-duration $t-type;
&:before,&:after{
content:'';
position: absolute;
left: 0;
top: 0;
width:0;
height:0;
transition: width $t-duration ($t-duration*3) $t-type, height $t-duration ($t-duration*2) $t-type, border ($t-duration/5) ($t-duration*4) $t-type;
border: solid transparent;
border-width: 3px 3px 0 0;
}
&:after{
left: auto;
top: auto;
bottom: 0;
right: 0;
transition: width $t-duration $t-duration $t-type, height $t-duration $t-type, border ($t-duration/5) ($t-duration*2) $t-type;
border-width: 0 0 3px 3px;
}
&:hover{
&:before,&:after{
transition: width $t-duration $t-type, height $t-duration $t-duration $t-type, border ($t-duration/5) $t-type;
width: 100%;
height: 100%;
border-color: $dbc;
}
&:after{
transition: width $t-duration ($t-duration*2) $t-type, height $t-duration ($t-duration*3) $t-type, border ($t-duration/5) ($t-duration*2) $t-type;
}
}
}
$shadow : 0 6px 10px -2px rgba(0, 0, 0, .25);
$solid: #ffc107;
$dbc: #3D5A68;
#body {
@include respondToAbove(sm){
padding: 1px;
}
@include respondTo(xs){
padding: 1px;
}
background: $dbc;
min-height: 150vh;
font-family: 'Josefin Sans', sans-serif;
text-transform: captalize;
letter-spacing: 2px;
&, & *{
transition: all .25s;
}
.out-wrap {
position: relative;
padding: 30px;
box-shadow: 0 6px 10px -2px rgba(0, 0, 0, .25);
width: 400px;
margin: 50px auto;
background: $solid;
#tabs{
border-bottom: 0;
margin: 0 -50px 20px;
background: #303030;
display: flex;
overflow-x: scroll;
overflow-y: hidden;
box-shadow: 0 0 10px rgba(0,0,0,.5);
flex-wrap: nowrap !important;
&::-webkit-scrollbar{
display: none;
}
li{
width: auto;
white-space: nowrap;
flex: 1 ;
a{
border: 0;
border-radius: 0;
cursor: pointer;
margin:0;
color: #fff;
text-transform: uppercase;
&:hover{
background: #ddd;
color: #303030;
}
}
&.active {
a{
background: #fff;
color: $dbc;
}
}
}
}
.tab-content{
overflow: hidden !important;
}
}
}
$.fn.tabbing = function (options) {
var opts = {delayTime : 300};
options = options || {};
opts = $.extend(opts,options);
return this.each(function () {
$(this).on('click', function (event) {
event.preventDefault();
var sum = 0;
$(this).prevAll().each(function(){ sum += $(this).width();});
var get = document.getElementById('tabs').scrollWidth
var dist = sum - ( $(this).parent().width() - $(this).width()) / 2;
if(dist < 0){
dist = 0;
}
/* else if(dist+sum > get){
dist = get-sum+dist+dist;
} */
$(this).parent().animate({
scrollLeft: dist
},opts['delayTime']);
});
});
};
$('#tabs li').tabbing();
$('#tabs li').click(function(){
var hashit = $(this).find('a').attr('href')
var autoHeight = $(hashit).height() + 30;
$('.tab-content').animate({height: autoHeight}, 100);
});
Also see: Tab Triggers