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.
<!--
https://docs.google.com/uc?id=0B7UPM0QugWUjQVlzT0VpTmdYbG8
https://docs.google.com/uc?id=id=0B7UPM0QugWUjM3hoVjU5VURYQlk
https://docs.google.com/uc?id=0B7UPM0QugWUjbkR2Um9YZ2pnNzQ
https://docs.google.com/uc?id=0B7UPM0QugWUjNVVVay1vYkRIV1E
https://docs.google.com/uc?id=0B7UPM0QugWUjOW1IZUhQWFhxN2c
https://docs.google.com/uc?id=0B7UPM0QugWUjR1p1VmRUNVpRZFU
-->
<div class="wrapper">
<div class="row">
<section class="header">
<h1>Animated Fancy Cards</h1>
<p>Showcases how you can use micro-interactions to fancy up your standard block / grid layouts. Each card shows additional info when you hover / select them</p>
</section>
<section class="cards cf">
<article class="fancy-card one">
<div class="bg-overlay"></div>
<div class="v-border"></div>
<div class="h-border"></div>
<div class="content">
<div class="primary">
<h2>Dev Catch-Up</h2>
</div>
<div class="secondary">
<h3>Catch up with the devs </h3>
<p>10/11/2016 - 4.00pm</p>
<p>Come and join us for our next upcoming developer catch up. See what the devs do</p>
<a class="button">Book Today</a>
</div>
</div>
</article>
<article class="fancy-card two">
<div class="bg-overlay"></div>
<div class="v-border"></div>
<div class="h-border"></div>
<div class="content">
<div class="primary">
<h2>New Tech Insights</h2>
</div>
<div class="secondary">
<h3>Get the latest news</h3>
<p>02/01/2017 - 3.30pm</p>
<p>Join an indepth discussion from our team of experts on the latest tech news</p>
<a class="button">Book Today</a>
</div>
</div>
</article>
<article class="fancy-card three">
<div class="bg-overlay"></div>
<div class="v-border"></div>
<div class="h-border"></div>
<div class="content">
<div class="primary">
<h2>Updated Research</h2>
</div>
<div class="secondary">
<h3>It's all new and improved</h3>
<p>12/02/2017 - 1.30pm</p>
<p>We look at our updated research techniques and how everything has changed</p>
<a class="button">Book Today</a>
</div>
</div>
</article>
</section>
</div>
</div>
body{
font-family: 'Roboto', sans-serif;
font-weight: 400;
}
h1,h2,h3,h4,h5,h6{
font-family: 'Source Sans Pro', sans-serif;
font-weight: 900;
letter-spacing: 0.25px;
}
.wrapper{
padding: 30px 15px;
}
.row{
max-width: 1024px;
margin: 0px auto;
}
*,*:before,*:after{
box-sizing: border-box;
}
.cf:before,
.cf:after{
display: table;
content: " ";
}
.cf:after{
clear: both
}
.header{
text-align: center;
padding: 0px 15px;
margin-bottom: 30px;
}
.header h1{
font-size: 2.8rem;
}
.header p{
font-size: 1.3rem;
line-height: 150%;
}
/*fancy card styling*/
.cards{
}
.fancy-card{
background: #eee;
width: 100%;
display: block;
float: left;
position: relative;
box-shadow: 0px 0px 0px 0px rgba(0, 0, 0, 0);
transition: all 250ms ease-in;
min-height: 300px;
background-size: cover;
background-position: center center;
margin-bottom: 30px;
}
.fancy-card.one{
background-image: url("https://docs.google.com/uc?id=0B7UPM0QugWUjQVlzT0VpTmdYbG8");
}
.fancy-card.two{
background-image: url("https://docs.google.com/uc?id=0B7UPM0QugWUjbkR2Um9YZ2pnNzQ");
}
.fancy-card.three{
background-image: url("https://docs.google.com/uc?id=0B7UPM0QugWUjNVVVay1vYkRIV1E");
}
.fancy-card .bg-overlay{
background: rgba(0,0,0,0.25);
position: absolute;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
transition: all 200ms linear;
}
.fancy-card .content{
padding: 30px 40px;
color: #fff;
text-align: center;
position: absolute;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
display: flex;
flex-wrap: nowrap;
align-items: center;
flex-direction: row;
}
.fancy-card .content .primary{
text-transform: uppercase;
width: 100%;
transition: all 250ms ease-out 200ms;
opacity: 1;
transform: translate3d(0px, 0px, 1px);
}
.fancy-card .content .secondary{
position: absolute;
opacity: 0;
left: 0px;
transform: translate3d(0px, 30px, 1px);
transition: all 200ms linear 0ms;
padding-left: 35px;
padding-right: 35px;
}
.fancy-card .button{
border: solid 1px #fff;
padding: 8px 12px;
display: inline-block;
border-radius: 2px;
margin: 12px auto;
}
/*horizontal border elements (top & bottom)*/
.fancy-card .v-border{
position: absolute;
top: 0%;
left: 0%;
width: 100%;
height: 100%;
}
.fancy-card .v-border:before,
.fancy-card .v-border:after{
width: 0%;
height: 1px;
left: 50%;
transition: all 250ms ease-out;
background: #fff;
}
.fancy-card .v-border:before{
content: '';
top: 10%;
position: absolute;
}
.fancy-card .v-border:after{
content: '';
bottom: 10%;
position: absolute;
}
/*horizontal elements (left & right)*/
.fancy-card .h-border{
position: absolute;
top: 0%;
left: 0%;
width: 100%;
height: 100%;
}
.fancy-card .h-border:before,
.fancy-card .h-border:after{
height: 0%;
top: 50%;
width: 1px;
transition: all 250ms ease-out;
background: #fff;
}
.fancy-card .h-border:before{
content: '';
left: 10%;
height: 0%;
position: absolute;
}
.fancy-card .h-border:after{
content: '';
right: 10%;
position: absolute;
}
/*hover states for interactivity*/
.fancy-card:active .v-border:before,
.fancy-card:active .v-border:after,
.fancy-card:hover .v-border:before,
.fancy-card:hover .v-border:after{
width: 90%;
left: 5%;
}
.fancy-card:active .h-border:before,
.fancy-card:active .h-border:after,
.fancy-card:hover .h-border:before,
.fancy-card:hover .h-border:after{
height: 90%;
top: 5%;
}
/*hovering over card, shadow effect*/
.fancy-card:active,
.fancy-card:hover{
box-shadow: 10px 10px 0px 0px rgba(0, 0, 0, 0.3);
}
/*hovering over card, adjust primary element*/
.fancy-card:active .content .primary,
.fancy-card:hover .content .primary{
opacity: 0;
transform: translate3d(0px, 20px, 1px);
transition: all 200ms linear 0ms;
}
/*hoverijng over card, adjust secondary element*/
.fancy-card:active .content .secondary,
.fancy-card:hover .content .secondary{
opacity: 1;
transform: translate3d(0px, 0px, 1px);
transition: all 200ms linear 200ms;
}
/*hovering over card, adjust background overlay*/
.fancy-card:active .bg-overlay,
.fancy-card:hover .bg-overlay{
background: rgba(0,0,0,0.45);
}
/*medium and large profiles*/
@media screen and (min-width: 768px){
.fancy-card{
width: 30%;
margin: 0% 1.66% 3.33% 1.66%;
}
}
Also see: Tab Triggers