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 Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
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.
#wrapper
.card.card1
.content
.inner
%h1.word This
%h3{"data-text" => "02"} 02
%p Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Aenean posuere, tortor sed cursus feugiat, nunc augue blandit nunc.
.card.card2
.content
.inner
%h1.word Check
%h3{"data-text" => "01"} 01
%p Nulla consequat massa quis enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. In ac felis quis tortor malesuada pretium.
.card.card3
.content
.inner
%h1.word Out
%h3{"data-text" => "04"} 04
%p Nullam accumsan lorem in dui. Donec vitae orci sed dolor rutrum auctor. Curabitur vestibulum aliquam leo.
.card.card4
.content
.inner
%h1.word Thing
%h3{"data-text" => "03"} 03
%p Fusce risus nisl, viverra et, tempor et, pretium in, sapien. In hac habitasse platea dictumst. Nam adipiscing.
#trigger
body{
display:flex;
justify-content:center;
align-items:center;
height:100vh;
background:radial-gradient(circle at center, #555, #222);
font-family:'Acme';
perspective:600px;
*{
transform-style:preserve-3d;
backface-visibility:hidden;
&:before, &:after{
transform-style:preserve-3d;
backface-visibility:hidden;
}
}
#wrapper{
width:700px;
height:500px;
position:relative;
overflow:hidden;
box-shadow:0 20px 40px -10px rgba(0,0,0,0.25);
&.flash{
animation:bend 2s cubic-bezier(0.175, 0.885, 0.32, 1.275) 1 forwards;
@keyframes bend{
0%{
transform:rotateY(0deg);
}
20%{
transform:rotateY(2.5deg);
}
50%{
transform:rotateY(0deg);
}
100%{
transform:rotateY(0deg);
}
}
}
#trigger{
position:absolute;
width:20px;
height:20px;
box-shadow:0 0 0 1px #ccc, 0 0 0 1px #ccc;
z-index:999;
border-radius:100%;
left:calc(12.5% - 12.5px);
top:calc(50% - 12.5px);
transition:background 0.2s ease-in-out, opacity 0.2s ease-in-out;
cursor:pointer;
&:hover{
background:#ccc;
&:before{
color:#222;
}
}
&.flash{
transition:box-shadow 0.2s ease-in-out, opacity 0.2s ease-in-out;
transition-delay:0s, 0.2s;
box-shadow:0 0 0 1px #ccc, 0 0 0 10px transparent;
opacity:0;
pointer-events:none;
}
&:before{
content:'→';
position:absolute;
color:#ccc;
top:50%;
left:50%;
transform:translate(-50%, -50%);
transition:0.2s ease-in-out;
}
}
&.fade{
opacity:0.25;
}
.card{
width:100%;
height:100%;
position:absolute;
top:0;
pointer-events:none;
z-index:0;
transition:transform 0.4s ease-in-out;
.content{
width:100%;
height:100%;
position:absolute;
left:0;
top:0;
overflow:hidden;
background:linear-gradient(to bottom, transparent calc(50% - 1px), rgba(0,0,0,0.05) calc(50% - 1px), rgba(0,0,0,0.05) 50%, transparent 50%), linear-gradient(to right, transparent calc(56% - 1px), rgba(0,0,0,0.05) calc(56% - 1px), rgba(0,0,0,0.05) 56%, transparent 56%), #ccc;
background-size:100%, 100% 50%, 100%;
background-repeat:no-repeat;
background-position:50%, 50% 100%, 50%;
h1{
opacity:1;
position:absolute;
left:calc(25% + 40px);
top:20px;
font-size:120px;
margin:0px;
color:rgba(0,0,0,0.175);
text-transform:uppercase;
}
p{
position:absolute;
width:22.5%;
height:40%;
display:inline-block;
bottom:0;
left:calc(25% + 40px);
line-height:1.5;
font-family:"Montserrat";
font-size:14px;
color:#555;
padding:5px;
box-sizing:border-box;
transition:0.3s ease-in-out;
clip-path: polygon(0 0, 0 0, 0 100%, 0% 100%);
}
h3{
position:absolute;
right:-200px;
top:20px;
font-size:80px;
margin:0;
color:transparent;
overflow:hidden;
border-bottom:1px solid rgba(0,0,0,0.175);
transform:scaleX(0);
transform-origin:left;
transition:transform 0s ease-in-out, right 0.4s ease-in-out;
transition-delay:0.6s, 0s;
padding:0 10px;
&:before{
content:attr(data-text);
color:transparent;
-webkit-text-stroke:0.25px rgba(0,0,0,0.25);
position:absolute;
transform:translateY(125%) skewY(45deg);
transition:0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
transition-delay:0.4s;
left:10px;
top:0;
}
}
&:before{
opacity:0;
z-index:2;
transition:0.2s ease-in-out;
}
&:before, &:after, .inner{
content:'';
position:absolute;
width:112.5%;
height:100%;
left:12.5%;
top:0;
background-size:cover;
transition:0.5s ease-in-out;
}
&:after{
background:transparent;
transition:0.5s ease-in-out;
}
&:before, .inner:after{
filter:saturate(0);
}
.inner{
width:40%;
height:45%;
left:auto;
right:0%;
z-index:999;
top:auto;
bottom:0;
transform-origin:left;
transform:scaleX(0);
overflow:hidden;
&:before, &:after{
content:'';
position:absolute;
width:100%;
height:100%;
background:#222;
left:0;
top:0;
z-index:2;
transform:scaleX(1);
transform-origin:right;
}
&:after{
background-size:cover;
z-index:1;
transform-origin:50% 50%;
transform:scale(1.5);
}
}
}
&.card1{
.content{
&:before, .inner:after{
background-image:url('https://images.unsplash.com/photo-1558845530-c8963f0c26fa?ixlib=rb-1.2.1&auto=format&fit=crop&w=1650&q=80');
}
}
}
&.card2{
.content{
&:before, .inner:after{
background-image:url('https://images.unsplash.com/photo-1558848369-839e86bc7f84?ixlib=rb-1.2.1&auto=format&fit=crop&w=1650&q=80');
}
}
}
&.card3{
.content{
&:before, .inner:after{
background-image:url('https://images.unsplash.com/photo-1558775723-1f9ca54bb7cd?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2767&q=80');
}
}
}
&.card4{
.content{
&:before, .inner:after{
background-image:url('https://images.unsplash.com/photo-1558848618-ce2c2e7bb671?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1650&q=80');
}
}
}
&:first-of-type{
pointer-events:all;
left:0;
animation:scaleIn 1s ease-in-out 1 forwards;
animation-delay:0s;
transform:translateX(-100%);
@keyframes scaleIn{
from{
transform:translateX(-100%);
}
to{
transform:translateX(-75%);
}
}
z-index:11;
.content{
&:before{
opacity:0.25;
animation:scaleDown 0.75s ease-in-out 1 forwards;
animation-delay:0.25s;
transform:translateX(6.75%);
@keyframes scaleDown{
to{
transform:translateX(0);
}
}
}
&:after{
background:#222;
}
}
}
&:nth-of-type(2){
z-index:10;
animation:scaleIn2 1s ease-in-out 1 forwards;
will-change:transform;
@keyframes scaleIn2{
from{
transform:translateX(-75%);
}
to{
transform:translateX(0%);
}
}
.content{
p{
transition-delay:1.85s;
clip-path: polygon(0 0, 100% 0, 100% 100%, 0% 100%);
}
&:after{
transition-delay:0.5s;
}
h3{
transition:transform 0.2s ease-in-out;
right:20px;
transform:scaleX(1);
transition-delay:2s;
&:before{
transform:translateY(0%);
transition:0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
transition-delay:2.25s;
}
}
h1{
right:100px;
}
.inner{
animation:scaleIn4 0.5s ease-in-out 1 forwards;
animation-delay:1.35s;
will-change:transform;
clip-path: polygon(0 0, 100% 0, 100% 100%, 0% 100%);
@keyframes scaleIn4{
to{
transform:scaleX(1);
}
}
&:after{
animation:scaleUp 1s ease-in-out 1 forwards;
animation-delay:1.9s;
will-change:transform;
@keyframes scaleUp{
to{
transform:scale(1);
}
}
}
&:before{
animation:scaleIn5 0.35s ease-in-out 1 forwards;
animation-delay:1.75s;
will-change:transform;
@keyframes scaleIn5{
to{
transform:scaleX(0);
}
}
}
}
&:before{
animation:scaleIn3 1.5s ease-in-out 1 forwards;
animation-delay:0.15s;
opacity:1;
will-change:transform;
@keyframes scaleIn3{
0%{
transform:translateX(0%);
clip-path: polygon(0% 0, 100% 0, 100% 100%, 0% 100%);
}
50%{
transform:translateX(-12.5%);
clip-path: polygon(0% 0, 100% 0, 100% 100%, 0% 100%);
}
100%{
transform:translateX(-12.5%);
clip-path: polygon(100% 0, 100% 0, 100% 100%, 100% 100%);
}
}
}
}
}
&:nth-of-type(3){
z-index:3;
.content{
&:before, &:after{
opacity:0;
transition:0s;
transition-delay:0s;
}
.inner{
transform:scaleX(1);
transition:0.5s ease-in-out;
clip-path: polygon(100% 0, 100% 0, 100% 100%, 100% 100%);
&:before{
display:none;
}
&:after{
transform:scale(1);
}
}
}
}
}
}
}
/*
* based on this dribbble shot by Andrew Baygulov: https://dribbble.com/shots/6427548-Kaiser-Slideshow
*/
(function ($) {
var isActive = false;
$.fn.shuffleText = function(shuffleResult, options){
var $this = $(this);
// Add/Remove Chars You Want To Appear During Shuffle In This Array
var aChars = new Array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","k","r","s","t","u","v","w","x","y","z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z");
// Defaults Settings
var defaults = $.extend({
time : 40, // Time In ms (Milliseconds) Of Shuffle For Each Letter
maxTime : 1000, // Max Time In ms (Milliseconds) Of Global Shuffle
amount : 3, // Amount Of Shuffle For Each Letter
complete : null // Do Something When Shuffle Is Completed
}, options);
if(shuffleResult == undefined)
shuffleResult = '';
// Init Variables
var aToShuffle = $this.text().split(''),
aShuffleResult = shuffleResult.split(''),
iFlag = 0, n = 0, duration = 0, iLenght = 0,
interval, aLetters;
if(!isActive){
isActive = true;
// Launch Shuffle
return $this.each(function(){
replaceEntry();
aLetters = $this.find('span');
// Debugging
if(defaults.amount < 0)
defaults.amount = 0;
// Calculate Duration Of Global Shuffle
if((iLength * (defaults.amount + 1) * defaults.time) > defaults.maxTime){
duration = defaults.maxTime / (iLength * (defaults.amount + 1));
}else{
duration = defaults.time;
}
randomChars();
interval = setInterval(randomChars,Math.floor(duration));
// Create The Correct DOM Structure
function replaceEntry(){
$this.empty();
if(aToShuffle.length > aShuffleResult.length)
iLength = aToShuffle.length;
else
iLength = aShuffleResult.length;
for(i = 0; i < iLength; i++){
if(aToShuffle[i] == undefined)
$this.append($('<span></span>'));
else
$this.append($('<span>'+aToShuffle[i]+'</span>'));
}
}
// The Shuffle Function
function randomChars(){
var randomChars = aChars[Math.floor(Math.random() * aChars.length)];
if(iFlag >= iLength){
isActive = false;
$this.text(shuffleResult);
clearInterval(interval);
if(typeof defaults.complete == 'function')
defaults.complete.call($this);
}else{
if(n == defaults.amount){
if(iFlag >= aShuffleResult.length)
$(aLetters[iFlag]).text('');
else
$(aLetters[iFlag]).text(aShuffleResult[iFlag]);
iFlag++; n = 0;
}else{
$(aLetters[iFlag]).text(randomChars);
n++;
}
}
}
});
}
};
}(jQuery));
$("#trigger").click(function(){
$('.card').removeClass("active");
$('#wrapper').prepend($('#wrapper .card:last'));
$(this).addClass("flash");
$('#wrapper').addClass("flash");
$('.card:nth-of-type(2)').addClass("active");
$text = $('.active .word').text();
setTimeout(function(){
$(".active .word").shuffleText($text, {
frames : 2000,
maxSpeed : 1,
amount : 35,
complete : null
});
}, 1200);
setTimeout(function(){
$("#trigger").removeClass("flash");
$("#wrapper").removeClass("flash");
}, 2000);
});
Also see: Tab Triggers