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.
<svg style="display:none;">
<defs>
<symbol viewBox="0 0 23.333 22.167" id="star">
<polygon fill="#FFFFFF" points="11.667,17.818 18.877,22.167 16.969,13.966 23.333,8.451 14.944,7.731 11.667,0 8.389,7.731
0,8.451 6.364,13.966 4.457,22.167 "/>
</symbol>
</defs>
</svg>
<main>
<section class="articles">
<h2 class="section__title">Articles</h2>
<p class="section__summary">Articles that have been written about SVG.</p>
<ul class="resources">
<li class="resource--article"><a href="" class="resource__link">
<h1 class="resource__title">Resource Title about animation</h1>
<p class="resource__summary">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aspernatur magni aut veniam ullam sunt magnam repellat dolor praesentium, aliquid, veritatis, ipsa consectetur maiores?</p>
<p class="resource--article__author"><span>By: </span>David Johnson</p>
<div class="recommended"><svg viewBox="0 0 23.333 22.167"><use xlink:href="#star"></use></svg>RECOMMENDED</div>
</a></li>
<li class="resource--article"><a href="" class="resource__link">
<h1 class="resource__title">Resource Title about animation</h1>
<p class="resource__summary"></p>
<p class="resource--article__author"><span>By: </span>David Johnson</p>
</a></li>
<li class="resource--article"><a href="" class="resource__link">
<h1 class="resource__title">Resource Title about animation</h1>
<p class="resource__summary">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aspernatur magni aut veniam ullam sunt magnam repellat dolor praesentium, aliquid, veritatis, ipsa consectetur maiores?</p>
<p class="resource--article__author"><span>By: </span>David Johnson</p>
</a></li>
<li class="resource--article"><a href="" class="resource__link">
<h1 class="resource__title">Resource Title about animation</h1>
<p class="resource__summary">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aspernatur magni aut veniam ullam sunt magnam repellat dolor praesentium, aliquid, veritatis, ipsa consectetur maiores?Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laboriosam maxime doloribus et officiis magnam quos ipsam, maiores ex numquam!</p>
<p class="resource--article__author"><span>By: </span>David Johnson</p>
</a></li>
<li class="resource--add">
<h1 class="resource--add__title">Add Article</h1>
<div class="resource__add-icon">
<div class="resource--add__iconcircle"></div>
<svg class="add" version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 60">
<polygon fill="#FFFFFF" points="44.677,27.404 44.677,33.404 32.677,33.404 32.677,45.404 26.677,45.404 26.677,33.404 14.677,33.404 14.677,27.404 26.677,27.404 26.677,15.404 32.677,15.404 32.677,27.404 "/>
</svg>
</div>
<p class="resource--add__summary">C'Mon and contribute you know you want to</p>
<div class="resource--add__card"></div>
</li>
</ul>
</section>
<section class="books">
<h2 class="section__title">Books</h2>
<p class="section__summary">Books that have been written about SVG.</p>
<ul class="resources">
<li class="resource--book"><a href="" class="resource__link">
<h1 class="resource__title">Resource Title Latest & Greatest</h1>
<p class="resource__summary">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore doloribus, necessitatibus, nostrum molestiae quis ratione accusantium eveniet unde error adipisci amet reprehenderit cupiditate ipsum sint veniam accusamus, nemo culpa labore.</p>
<p class="resource--book__author"><span>By: </span>Joe Dirt</p>
<p class="resource--book__publisher"><span>Published By: </span>O'Reiley</p>
<div class="recommended"><svg viewBox="0 0 23.333 22.167"><use xlink:href="#star"></use></svg>RECOMMENDED</div>
</a></li>
<li class="resource--book"><a href="" class="resource__link">
<h1 class="resource__title">Resource Title Latest & Greatest</h1>
<p class="resource__summary">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore doloribus, necessitatibus, nostrum molestiae quis ratione accusantium eveniet unde error adipisci amet reprehenderit cupiditate ipsum sint veniam accusamus, nemo culpa labore.</p>
<p class="resource--book__author"><span>By: </span>Joe Dirt</p>
<p class="resource--book__publisher"><span>Published By: </span>5 Simple Steps</p>
</a></li>
<li class="resource--book"><a href="" class="resource__link">
<h1 class="resource__title">Resource Title Latest & Greatest</h1>
<p class="resource__summary">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore doloribus, necessitatibus, nostrum molestiae quis ratione accusantium eveniet unde error adipisci amet reprehenderit cupiditate ipsum sint veniam accusamus, nemo culpa labore.</p>
<p class="resource--book__author"><span>By: </span>Joe Dirt</p>
<p class="resource--book__publisher"><span>Published By: </span>O'Reiley</p>
</a></li>
<li class="resource--add">
<h1 class="resource--add__title">Add Article</h1>
<div class="resource__add-icon">
<svg class="add" version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 60">
<circle cx="30" cy="30" r="30" />
<polygon fill="#FFFFFF" points="44.677,27.404 44.677,33.404 32.677,33.404 32.677,45.404 26.677,45.404 26.677,33.404 14.677,33.404 14.677,27.404 26.677,27.404 26.677,15.404 32.677,15.404 32.677,27.404 "/>
</svg>
</div>
<p class="resource--add__summary">C'Mon and contribute you know you want to</p>
<div class="resource--add__card"></div>
</li>
</ul>
</section>
<section class="talks">
<h2 class="section__title">Talks</h2>
<p class="section__summary">Talks that have been given about SVG.</p>
<ul class="resources">
<li class="resource--talks"><a href="" class="resource__link">
<h1 class="resource__title">Resource Title</h1>
<p class="resource__summary">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptatibus libero aliquid sapiente unde </p>
<p class="resource--talks__author"><span>By: </span>Johnny U</p>
<div class="recommended"><svg viewBox="0 0 23.333 22.167"><use xlink:href="#star"></use></svg>RECOMMENDED</div>
</a></li>
<li class="resource--talks"><a href="" class="resource__link">
<h1 class="resource__title">Resource Title About Some Other Stuff</h1>
<p class="resource__summary">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptatibus libero aliquid sapiente unde Lorem ipsum dolor sit amet, consectetur adipisicing elit. </p>
<p class="resource--talks__author"><span>By: </span>Johnny U</p>
</a></li>
<li class="resource--talks"><a href="" class="resource__link">
<h1 class="resource__title">Resource Title</h1>
<p class="resource__summary">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nulla tenetur fugit iusto minus vitae distinctio eligendi, dolore sapiente aspernatur quo? Vel tempore pariatur assumenda, molestias, inventore commodi. Molestiae, excepturi. </p>
<p class="resource--talks__author"><span>By: </span>Johnny U</p>
</a></li>
<li class="resource--talks"><a href="" class="resource__link">
<h1 class="resource__title">Resource Title</h1>
<p class="resource__summary">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptatibus libero aliquid sapiente unde </p>
<p class="resource--talks__author"><span>By: </span>Johnny U</p>
</a></li>
<li class="resource--add">
<h1 class="resource--add__title">Add Talk</h1>
<div class="resource__add-icon">
<svg class="add" version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 60">
<circle cx="30" cy="30" r="30" />
<polygon fill="#FFFFFF" points="44.677,27.404 44.677,33.404 32.677,33.404 32.677,45.404 26.677,45.404 26.677,33.404 14.677,33.404 14.677,27.404 26.677,27.404 26.677,15.404 32.677,15.404 32.677,27.404 "/>
</svg>
</div>
<p class="resource--add__summary">C'Mon and contribute you know you want to</p>
<div class="resource--add__card"></div>
</li>
</ul>
</section>
</main>
@import "compass/css3";
.resource--add__iconcircle {
position: absolute;
transform:translateX(-50%);
left:50%;
border-radius:50%;
width: 100px;
height: 100px;
background-color: #000;
}
// variables
$font-family__primary: 'roboto','helvetica';
$font-weight--thin : 100;
$font-weight--light : 300;
$font-weight--norm : 400;
$font-weight--medium : 500;
$font-weight--bold : 700;
$font-weight--ultra-bold : 900;
$break-points: (
xs : 20em,
sm : 37.5em,
md : 50em,
lg : 65em,
xl : 75em
);
$color-palettes : (
gray : (
light: lighten(#202020,40%),
base: #202020,
),
red : (
base: #FF1643,
dark: #d40000,
),
turquoise: (
base: #1CE8B5,
dark: #00bea4
),
pink : (
base: #eb3f79,
dark: #d71a5f
)
);
@function palette($palette, $shade: 'base') {
@return map-get(map-get($color-palettes, $palette), $shade);
}
@function bkpt($breakpoint) {
@return map-get($break-points, $breakpoint);
}
// mixins
@mixin e($element) {
&__#{$element} {
@content;
}
}
@mixin m($modifier) {
&--#{$modifier} {
@content;
}
}
// Media queries
@mixin mq($break) {
@if $break == "xs" {
@media screen and ( min-width: bkpt(xs) ) {
@content;
}
}
@else if $break == "sm" {
@media screen and ( min-width: bkpt(sm) ) {
@content;
}
}
@else if $break == "md" {
@media screen and ( min-width: bkpt(md) ) {
@content;
}
}
@else if $break == "lg" {
@media screen and ( min-width: bkpt(lg) ) {
@content;
}
}
@else if $break == "xl" {
@media screen and ( min-width: bkpt(xl) ) {
@content;
}
}
@else {
@media screen and ( min-width: $break ) {
@content;
}
}
}
// Base styles
%clearfix {
&:after {
content: "";
display: table;
clear: both;
}
}
*,* > *{
box-sizing:border-box;
padding:0;
margin:0;
}
body{
font-family: $font-family__primary ;
background-color: #f4f4f4;
}
main {
padding:2rem 0;
max-width:1350px;
margin:0 auto;
}
a{
text-decoration: none;
color: palette(gray);
}
%resource{
position: relative;
background-color: #fff;
width: 90%;
margin:0 auto;
list-style-type: none;
padding:.5rem 1.75rem 3rem;
border-top: 15px solid palette(red);
margin-bottom: 1.75rem;
border-radius: 5px;
transition:all .5s cubic-bezier(.4,0,.2,1);
&:hover {
&:before{
box-shadow: 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
&:after {
box-shadow: 0 8px 17px 0 rgba(0, 0, 0, 0.2);
}
}
&:before,
&:after{
content:'';
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
box-shadow: 0 2px 10px 0 rgba(0, 0, 0, 0.16);
border-radius:inherit;
z-index:-1;
transition:all .2s cubic-bezier(.4,0,.2,1);
}
&:after {
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.26);
}
@include mq(sm) {
width: 80%;
}
@include mq(md) {
float:left;
margin-left: 2.5%;
width: 46%;
}
@include mq(xl) {
float:left;
width: 30%;
}
}
.resource {
@include e('title') {
font-weight: $font-weight__norm;
line-height: 1.2;
font-size: 1.6em;
margin-bottom: .75em;
}
@include e('summary') {
color: palette(gray,light);
line-height: 1.5;
font-size: 1em;
margin-bottom: 2em;
}
}
%author {
font-weight: $font-weight--medium;
letter-spacing:1px;
span {
font-style:italic;
color:palette(gray,light);
}
}
.resource--article{
@extend %resource;
@include e('author'){
@extend %author;
color: palette(red,dark);
}
}
.resource--book {
@extend %resource;
border-color: palette(turquoise);
@include e('author'){
@extend %author;
margin-bottom: .5rem;
color:palette(turquoise,dark);
}
@include e('publisher') {
@extend %author;
color:palette(turquoise,dark);
}
.resource--add{
border-color:palette(turquoise);
}
}
.resource--talks {
@extend %resource;
border-color: palette(pink);
@include e('author'){
@extend %author;
color:palette(pink,dark);
}
}
.resource--add{
@extend %resource;
svg {
cursor:pointer;
}
// .resource--add__title
@include e('title') {
@extend .resource__title;
text-align: center;
}
// .resource--add__summary
@include e('summary') {
@extend .resource__summary;
text-align: center;
}
// .resource--add__card
@include e('card') {
width: 0;
height: 0;
opacity:0;
top:0;
background-color: white;
border-radius:5px;
box-shadow:6px 6px 12px rgba(palette(gray,light),.4),-6px -6px 12px rgba(palette(gray,light),.4);
transition: all .2s cubic-bezier(.4,0,.2,1);
transform-origin: top top;
}
}
.resource__add-icon{
transition: all .2s cubic-bezier(.4,0,.2,1);
}
.icon-is-rotated {
transition: all .2s cubic-bezier(.4,0,.2,1);
transform: rotate(45deg);
}
section {
@extend %clearfix;
clear:both;
margin-bottom: 7rem;
}
.section {
@include e('title'){
margin-left:5%;
margin-bottom: .2rem;
font-size: 1.75rem;
font-weight: $font-weight--medium;
@include mq(sm){
margin-left: 10%;
}
@include mq(md){
margin-left: 2.5%;
}
}
@include e('summary') {
margin-left:5%;
margin-bottom: 1.5rem;
color: palette(gray,light);
line-height: 1.5;
font-size: 1.125em;
@include mq(sm){
margin-left: 10%;
}
@include mq(md){
margin-left: 2.5%;
}
}
}
.add {
width: 30%;
display:block;
margin:2.25rem auto 1.75rem;
position: relative;
z-index:100;
polygon {
transition:transform .4s ease,fill .6s ease;
transform-origin: center center;
}
/*&:active polygon{
transform:rotate(360deg);
}*/
}
.articles{
.section__title{
color:palette(red,dark);
}
.recommended{
background-color: palette(red,base);
}
.add {
circle{
fill:palette(red);
}
&:hover circle {
fill:lighten(palette(red),5%);
}
}
}
.books{
.resource--add{
border-color:palette(turquoise);
}
.section__title{
color:palette(turquoise,dark);
}
.recommended{
background-color: palette(turquoise,base);
}
.add {
circle{
fill:palette(turquoise);
}
&:hover circle {
fill:lighten(palette(turquoise),5%);
}
}
}
.talks{
.resource--add{
border-color:palette(pink);
}
.section__title{
color:palette(pink,dark);
}
.recommended{
background-color: palette(pink,base);
}
.add {
circle{
fill:palette(pink);
}
&:hover circle {
fill:lighten(palette(pink),5%);
}
}
}
// make sure last list-item always clears
.resources li{
@include mq(md) {
&:nth-child(2n+1){
clear:both;
}
}
@include mq(lg){
&:nth-child(3n+1){
clear:none;
}
}
@include mq(xl){
&:nth-child(2n+1){
clear:none;
}
}
}
.recommended {
color:white;
font-weight: $font-weight--light;
letter-spacing: 2px;
font-size: .8em;
text-transform: uppercase;
padding:.3rem .7rem;
position: absolute;
right:0;
bottom:0;
border-radius:0 0 5px 0;
svg{
width: 15px;
margin-right:8px;
position: relative;
top:2px;
}
}
.card-is-active
{
position: absolute;
width: 100vw;
height: 100vh;
background-color: red;
opacity:1;
top:0;
right:0;
z-index:200;
transition: all .2s cubic-bezier(.4,0,.2,1);
transform-origin: top right;
border-radius:0;
}
$('.resource__add-icon').on("click",function(){
$(this).toggleClass('icon-is-rotated');
$(this).children('.resource--add__iconcircle').toggleClass('card-is-active');
});
Also see: Tab Triggers