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 id="some-blog">
<!-- start post -->
<div class="blog-card">
<a href="/some-fake-content">
<img src="http://hdwarena.com/wp-content/uploads/2017/10/Free-Cool-Wallpaper-1366x768.jpg"></a>
<h2>Vestibulum ullamcorper tempus</h2>
<div class="preloaded-content">
<p>Proin faucibus sit amet nibh eget mollis. Nulla quis dignissim mi. Praesent dui ex, vehicula at tempus et, pharetra quis leo. Sed tincidunt, mauris a sodales tincidunt, elit lacus vulputate diam, a egestas orci turpis vel arcu. Vestibulum ut urna sed sapien consectetur rhoncus quis sit amet magna. Integer in feugiat nulla. Fusce in luctus enim. Vestibulum ullamcorper tempus nunc ut semper. Fusce convallis, lorem at pharetra faucibus, sem enim vestibulum felis, non dignissim velit felis eget dolor. Vestibulum vel felis erat. Morbi sodales sed mi facilisis ullamcorper. Nulla tincidunt augue et justo dapibus posuere. Maecenas eleifend lorem mattis malesuada euismod. Donec nec tellus quis velit commodo elementum id a dui.</p>
<p>Proin eu orci posuere, semper tortor vitae, varius est. Aliquam eu turpis eu tortor rutrum iaculis et at libero. Integer nulla risus, tempor eu lacus at, ornare ultrices ante. Duis lobortis elit lectus, et rhoncus augue pharetra nec. Suspendisse at enim vestibulum, pretium metus non, pretium tellus. Nullam sit amet dapibus ante. Etiam semper elit facilisis, molestie elit a, congue turpis. Phasellus id tincidunt purus. Ut eu tempor sem.</p>
</div>
</div>
<!-- end post -->
<!-- start post -->
<div class="blog-card">
<a href="/some-fake-content">
<img src="http://hdwarena.com/wp-content/uploads/2018/03/battlefield_4_naval_strike-wallpaper-1920x1080-1366x768.jpg"></a>
<h2>Quisque sodales, leo quis tincidunt</h2>
<div class="preloaded-content">
<p>Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed cursus fringilla ligula in vestibulum. Cras aliquet gravida justo sed finibus. Phasellus venenatis ipsum lorem, efficitur rutrum tellus fermentum vel. Vivamus molestie tellus tellus, quis pharetra nunc pulvinar in. Maecenas a lectus a sapien mollis suscipit mattis et nunc. Quisque sodales, leo quis tincidunt feugiat, justo purus ornare ex, vel molestie risus est non elit. Etiam blandit vestibulum ligula in tincidunt. Mauris aliquam nisi vitae elit vehicula maximus. Curabitur vitae neque lobortis, elementum libero nec, ultricies massa. Pellentesque efficitur nisl id nisi scelerisque sollicitudin. Etiam in tempus eros. Duis condimentum orci in nisi pretium, vitae luctus arcu molestie. Curabitur laoreet porttitor metus, ut aliquam quam cursus ut.</p>
<p>Duis id arcu eu orci consectetur commodo in vitae metus. Vivamus nec est metus. Duis malesuada, nunc vitae luctus tincidunt, risus turpis ultricies felis, non ultrices lorem odio ac enim. Duis turpis lorem, rhoncus eu auctor sit amet, eleifend non sapien. Morbi vestibulum nibh sit amet orci placerat, id bibendum lorem maximus. Vivamus tincidunt purus vel nulla convallis eleifend. Sed convallis eu orci sed egestas. Vestibulum facilisis vel quam eget aliquet.</p>
</div>
</div>
<!-- end post -->
<!-- start post -->
<div class="blog-card">
<a href="/some-fake-content">
<img src="https://thiswallpaper.com/cdn/hdwallpapers/799/beautiful%20scene%20game%20thrones%20wallpaper.jpg"></a>
<h2>Donec nibh mi fermentum</h2>
<div class="preloaded-content">
<p>Suspendisse ultricies euismod lobortis. Integer interdum lacus eget erat efficitur, id imperdiet sem sollicitudin. Proin et finibus arcu, non tristique quam. Donec sem nisi, pharetra non nulla nec, sodales commodo velit. Maecenas fringilla luctus erat, quis facilisis massa gravida a. Nullam vel semper erat. Aliquam sodales lacus eu laoreet vestibulum. Praesent sed sem orci. Suspendisse potenti. Integer tempor lorem in vehicula ultricies. Duis vestibulum id ipsum in condimentum. Donec ac sem eget ipsum porta accumsan et quis lectus. Vivamus suscipit hendrerit diam, eget tristique arcu rhoncus vel. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p>
<p>Vestibulum id consectetur diam, at congue tortor. Nam erat ipsum, gravida a eleifend a, sollicitudin ut metus. Vestibulum eu leo purus. Sed consequat et magna nec pellentesque. Morbi sit amet sem nunc. Morbi a orci vitae ligula ornare luctus vel non mauris. Donec nibh mi, fermentum quis libero ut, laoreet sagittis enim. Aliquam erat volutpat. Nullam justo massa, faucibus vel aliquam et, ullamcorper eget nibh. Quisque vitae facilisis leo. Nunc fringilla, lectus ac interdum placerat, ante enim sagittis eros, sit amet euismod erat neque et ex. Sed at leo eros.</p>
</div>
</div>
<!-- end post -->
</div>
html,body{ padding:0; margin: 0;}
#some-blog{
font-family: "San Francisco", Helvetica, Arial, sans-serif;
}
#some-blog.js .preloaded-content{
display: none;
padding: 1.5em;
}
#some-blog.js .preloaded-content p{
line-height: 1.4em;
}
#some-blog .blog-card.active .preloaded-content{
display: block;
}
.blog-card{
position: relative;
width: 200px;
height: 300px;
overflow: hidden;
border-radius: 5px;
margin: 24px auto;
cursor: pointer;
background: #efefef;
}
.blog-card.active{
position: absolute;
z-index: 100;
padding: 0;
margin: 0;
cursor: default;
}
.blog-card img{
width: auto;
height: 100%;
min-height: 300px;
transform: translateX(-25%);
}
.blog-card-background{
width: 100%;
height: 100%;
background-position: 50% 50%;
background-color: #333;
background-repeat: no-repeat;
background-size: cover;
position: relative;
}
.blog-card h2,
.blog-card-background h2{
color: white;
margin: 0;
padding: .25em;
position: absolute;
bottom: 0;
text-shadow: -2px 2px 3px black;
}
.blog-card .close{
position: absolute;
top: 1em;
right: 1em;
width: 32px;
height: 32px;
background: transparent url(https://media.wponlinesupport.com/wp-content/plugins/wpos-support-plus-responsive-ticket-system/asset/images/close_btn.png) no-repeat 50% 50%;
background-size: contain;
z-index: 100;
cursor: pointer;
opacity: .8;
overflow: hidden;
white-space: nowrap;
text-indent: 110%;
}
.blog-card.inactive .close{
display: none;
}
.blog-card .close:hover{
opacity: 1;
}
$('document').ready( function(){
$('#some-blog').addClass('js');
$('.blog-card').addClass('inactive');
$('.blog-card img').each( function(){
var blogCard = $(this).closest('.blog-card');
blogCard.prepend( '<div class="blog-card-background" style="background-image: url('+$(this).attr('src')+');"></div>');
blogCard.find('.blog-card-background').append( blogCard.find('h2') );
blogCard.prepend('<div class="close">Close</div>');
$(this).remove();
});
$('#some-blog').on( 'click' , '.blog-card.inactive' , function(){
// Should go to $(this).find('a').attr('href'); ... but we won't
// for the sake of the demo
$(this).removeClass('inactive').addClass('active');
cardAnimate = new TimelineMax();
cardAnimate
// These sets are in place so when reversed, all props are cleared
.set( $(this), {clearProps:"all"})
.set( $(this).find('.blog-card-background'), {clearProps:"height"})
.set( $(this).find('.preloaded-content'), {clearProps:"all"})
.set( $(this).find('h2'), {clearProps:"all"})
.set( $(this).find('.close'), {clearProps:"all"})
// These sets just kick a few things into position so the tween is middle out
.set( $(this).find('.blog-card-background'), { height: '400' } )
.set( $(this).find('.preloaded-content'), { autoAlpha: 0, y: 75 } )
.set( $(this), { x: '-50%', left: '50%', top: 0 } )
.set( $(this).find('h2'), {fontSize: '300%', y: -50, autoAlpha: 0 } )
.set( $(this).find('.close'), {y: -100, autoAlpha: 0 } )
// the actual tweens
.to( $(this).find('.blog-card-background'), .125, { height: '450', y: -50, ease:Power2.easeOut } )
.to( $(this) , .5 , { width: '100%', height: '100%', ease:Expo.easeIn }, "-=.125" )
.to( $(this).find('.blog-card-background'), .5, { height: '400', y: 0, ease:Power2.easeOut }, "-=.25" )
.to( $(this).find('h2') , .35 , { y: 0, autoAlpha: 1, ease:Power2.easeOut }, "-=.25" )
.to( $(this).find('.preloaded-content'), .75, { autoAlpha: 1, y: 0, ease: Power2.easeOut } , "-=.5")
.to( $(this).find('.close'), .75, { autoAlpha: 1, y: 0, ease: Power2.easeOut } );
$('#some-blog').on( 'click' , '.blog-card.active .close' , function(){
cardAnimate.reverse().timeScale(2).eventCallback("onReverseComplete", function(){$('.blog-card.active').removeClass('active').addClass('inactive');} );
});
})
});
Also see: Tab Triggers