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="tabs-wrapper">
<input type="radio" name="tab" id="tab1" class="tab-head" checked="checked" />
<label for="tab1">One</label>
<input type="radio" name="tab" id="tab2" class="tab-head" />
<label for="tab2">Two</label>
<input type="radio" name="tab" id="tab3" class="tab-head" />
<label for="tab3">Three</label>
<input type="radio" name="tab" id="tab4" class="tab-head" />
<label for="tab4">Four</label>
<div class="tab-body-wrapper">
<div id="tab-body-1" class="tab-body">
<h1>Tab 1 heading</h1>
<p>Bacon ipsum dolor sit amet pastrami dolor tri-tip, magna tongue ullamco occaecat velit shoulder sunt elit. Non cillum turkey short loin beef ribs. Anim qui shankle short ribs pancetta boudin. Occaecat mollit in laboris ham hock bresaola corned beef flank hamburger aute chicken id t-bone.</p>
</div>
<div id="tab-body-2" class="tab-body">
<h1>Tab 2 heading</h1>
<p>Bacon ipsum dolor sit amet pastrami dolor tri-tip, magna tongue ullamco occaecat velit shoulder sunt elit. Non cillum turkey short loin beef ribs. Anim qui shankle short ribs pancetta boudin. Occaecat mollit in laboris ham hock bresaola corned beef flank hamburger aute chicken id t-bone.</p>
</div>
<div id="tab-body-3" class="tab-body">
<h1>Tab 3 heading</h1>
<p>Bacon ipsum dolor sit amet pastrami dolor tri-tip, magna tongue ullamco occaecat velit shoulder sunt elit. Non cillum turkey short loin beef ribs. Anim qui shankle short ribs pancetta boudin. Occaecat mollit in laboris ham hock bresaola corned beef flank hamburger aute chicken id t-bone.</p>
</div>
<div id="tab-body-4" class="tab-body">
<h1>Tab 4 heading</h1>
<p>Bacon ipsum dolor sit amet pastrami dolor tri-tip, magna tongue ullamco occaecat velit shoulder sunt elit. Non cillum turkey short loin beef ribs. Anim qui shankle short ribs pancetta boudin. Occaecat mollit in laboris ham hock bresaola corned beef flank hamburger aute chicken id t-bone.</p>
</div>
</div>
</div>
@import "compass/css3";
@import url(https://fonts.googleapis.com/css?family=Raleway:100,200,300);
@import "compass/css3/transform";
@mixin font($font-size, $line-height, $font-family, $font-weight) {
font: #{$font-size}/#{$line-height} $font-family;
font-weight: $font-weight;
}
@mixin keyframe($animation_name) {
@keyframes #{$animation_name} {
@content;
}
}
@mixin animation($delay, $duration, $animation) {
animation-delay: $delay;
animation-duration: $duration;
animation-name: $animation;
animation-fill-mode: forwards;
}
@mixin breakpoint($point) {
@if $point == big {
@media screen and (max-width: 1600px) {
@content;
}
} @else if $point == medium {
@media screen and (max-width: 900px) {
@content;
}
} @else if $point == small {
@media screen and (max-width: 600px) {
@content;
}
}
}
@include keyframe(content-opacity) {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@include keyframe(content-rotate-y) {
from {
@include transform(rotateY(90deg));
}
to {
opacity: 1;
@include transform(rotateY(0deg));
}
}
@include keyframe(content-rotate-x) {
from {
@include transform(rotateX(90deg));
}
to {
opacity: 1;
@include transform(rotateX(0deg));
}
}
@include keyframe(content-rotate-both) {
from {
@include transform(rotate(90deg));
@include transform-origin(0% 50%);
}
to {
opacity: 1;
@include transform(rotate(0deg));
@include transform-origin(0% 50%);
}
}
@include keyframe(content-pop-out) {
0% {
opacity: 1;
@include transform(scale(1));
}
50% {
opacity: 1;
@include transform(scale(1.1));
}
100% {
opacity: 1;
@include transform(scale(1));
}
}
@include keyframe(content-pop-in) {
from {
opacity: 1;
@include transform(scale(1.1));
}
to {
opacity: 1;
@include transform(scale(1));
}
}
@include keyframe(content-slide-bot) {
from {
top: 20px;
opacity: 0;
}
to {
top: 0px;
opacity: 1;
}
}
@include keyframe(content-slide-top) {
from {
top: -20px;
opacity: 0;
}
to {
top: 0px;
opacity: 1;
}
}
/* used for wrapper animation after the load of the page */
@include keyframe(show) {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
$tab-head-color: #525252;
$tab-checked-border-color: #b8b63e;
$tab-border-color: #4d4c47;
$tab-text-color: #dbdbd3;
$tab-checked-text-color: #f2f2f2;
$tab-hover-color: #667876;
$tab-body-wrapper-color: #f7eec6;
$tab-delimiter-line-height: 5px;
$tab-label-height: 3em;
html {
background: url(http://distinctionjewelry.com/info/wp-content/uploads/2013/01/blurred-background-10-2000x1250.jpg);
webkit-font-smoothing: antialiased;
@include font(1em, 1.5em, "Raleway", normal);
}
.tabs-wrapper {
margin: 5% 10% 0 10%;
input[type="radio"] {
display: none;
}
label {
transition: background 0.4s ease-in-out, height 0.2s linear;
display: inline-block;
cursor: pointer;
color: $tab-text-color;
width: 20%;
height: $tab-label-height;
border-top-left-radius: 3px;
border-top-right-radius: 3px;
background: $tab-head-color;
text-align: center;
line-height: 3em;
&:last-of-type {
border-bottom: none;
}
&:hover {
background: $tab-hover-color;
/*@include transform (translate(0,-0.2em));*/
}
@include breakpoint(big) {
width: 15%;
}
@include breakpoint(medium) {
width: 20%;
}
@include breakpoint(small) {
width: 100%;
display: block;
border-bottom: 2px solid $tab-border-color;
border-radius: 0;
}
}
@include breakpoint(small) {
margin: 0;
}
}
#tab1,
#tab2,
#tab3,
#tab4 {
&:checked {
+ label {
background: $tab-checked-border-color;
color: $tab-checked-text-color;
}
}
}
.tab-body {
position: absolute;
top: -9999px;
// Set opacity to 1 if you won't use any animation which sets the opacity to 1
opacity: 0;
padding: 10px;
}
.tab-body-wrapper {
background: $tab-body-wrapper-color;
border-top: $tab-checked-border-color $tab-delimiter-line-height solid;
border-bottom-right-radius: 3px;
border-bottom-left-radius: 3px;
border-top-right-radius: 3px;
@include animation(0.2s, 1.5s, show);
@include breakpoint(small) {
border: none;
border-radius: 0;
}
}
#tab1:checked ~ .tab-body-wrapper #tab-body-1,
#tab2:checked ~ .tab-body-wrapper #tab-body-2,
#tab3:checked ~ .tab-body-wrapper #tab-body-3,
#tab4:checked ~ .tab-body-wrapper #tab-body-4 {
position: relative;
top: 0px;
/* Choose one - modify .tab-body opacity to 1 if you don't want any animation or set opacity to 1 here */
// @include animation(0.2s,0.8s,content-opacity);
// @include animation(0.2s,0.8s,content-rotate-x);
/* @include animation(0.2s,0.8s,content-rotate-y); */
/* @include animation(0.2s,0.8s,content-rotate-both); */
// @include animation(0.2s,0.8s,content-pop-in);
@include animation(0.1s,0.4s,content-pop-out);
/* @include animation(0.1s,1s,content-slide-bot); */
// @include animation(0.1s, 1s, content-slide-top);
}
/* checkout the commented parts of the scss */
Also see: Tab Triggers