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.
<input type="radio" id="grid" name="layout" checked />
<label for="grid" class="layout-1"></label>
<input type="radio" id="list" name="layout" />
<label for="list" class="layout-2"></label>
<!-- Apologies for the out-of-order-ness.
Moved them around to group them better. -->
<div class="blocks">
<div class="block block-2">2</div>
<div class="block block-3">3</div>
<div class="block block-12">12</div>
<div class="block block-23">23</div>
<div class="block block-9">9</div>
<div class="block block-4">4</div>
<div class="block block-5">5</div>
<div class="block block-6">6</div>
<div class="block block-8">8</div>
<div class="block block-10">10</div>
<div class="block block-22">22</div>
<div class="block block-7">7</div>
<div class="block block-15">15</div>
<div class="block block-29">29</div>
<div class="block block-30">30</div>
<div class="block block-11">11</div>
<div class="block block-1">1</div>
<div class="block block-26">26</div>
<div class="block block-13">13</div>
<div class="block block-14">14</div>
<div class="block block-16">16</div>
<div class="block block-19">19</div>
<div class="block block-20">20</div>
<div class="block block-18">18</div>
<div class="block block-21">21</div>
<div class="block block-24">24</div>
<div class="block block-25">25</div>
<div class="block block-17">17</div>
<div class="block block-27">27</div>
<div class="block block-28">28</div>
<div class="block block-31">31</div>
</div>
<p class="click">Click to Embiggen</p>
<div id="output"></div>
/* The Gradients ---------------------------------------- */
.block-1 {
background: -webkit-linear-gradient(135deg, #fddf50 20%, #65ca03 80%);
background: linear-gradient(135deg, #fddf50 20%, #65ca03 80%);
}
.block-2 {
background: -webkit-radial-gradient(#222222, #000000);
background: radial-gradient(#222222, #000000);
}
.block-3 {
background: -webkit-radial-gradient(#3c3b52, #252233);
background: radial-gradient(#3c3b52, #252233);
}
.block-4 {
background: -webkit-linear-gradient(-90deg, #4567b2 20%, #8ab9ff 80%);
background: linear-gradient(-90deg, #4567b2 20%, #8ab9ff 80%);
}
.block-5 {
background: -webkit-linear-gradient(155deg, #72abff 0%, #2c4784 90%);
background: linear-gradient(155deg, #72abff 0%, #2c4784 90%);
}
.block-6 {
background: -webkit-linear-gradient(-60deg, #8ab9ff 50%, #4567b2 50%);
background: linear-gradient(-60deg, #8ab9ff 50%, #4567b2 50%);
}
.block-7 {
background: -webkit-linear-gradient(135deg, #ffa000 20%, #ff5000 80%);
background: linear-gradient(135deg, #ffa000 20%, #ff5000 80%);
}
.block-8 {
background: -webkit-linear-gradient(-45deg, #141e31 50%, #233a54 50%);
background: linear-gradient(-45deg, #141e31 50%, #233a54 50%);
}
.block-9 {
background: -webkit-linear-gradient(right, #243B55, #141E30);
background: linear-gradient(to left, #243B55, #141E30);
}
.block-10 {
background: -webkit-linear-gradient(180deg, #243B55 50%, #141E30 50%);
background: linear-gradient(180deg, #243B55 50%, #141E30 50%);
}
.block-11 {
background: -webkit-linear-gradient(120deg, #fbef97 20%, #ffe41d 80%);
background: linear-gradient(120deg, #fbef97 20%, #ffe41d 80%);
}
.block-12 {
background: -webkit-linear-gradient(right, #232526, #414345);
background: linear-gradient(to left, #232526, #414345);
}
.block-13 {
background: -webkit-linear-gradient(right, #56ab2f, #a8e063);
background: linear-gradient(to left, #56ab2f, #a8e063);
}
.block-14 {
background: -webkit-linear-gradient(-45deg, #57ac30 50%, #a6df62 50%);
background: linear-gradient(-45deg, #57ac30 50%, #a6df62 50%);
}
.block-15 {
background: -webkit-linear-gradient(-45deg, #ff5000 50%, #ffa000 50%);
background: linear-gradient(-45deg, #ff5000 50%, #ffa000 50%);
}
.block-16 {
background: -webkit-radial-gradient(#13941d, #1d512a);
background: radial-gradient(#13941d, #1d512a);
}
.block-17 {
background: -webkit-linear-gradient(left, #b6eae1 10%, #D2FBAD 90%);
background: linear-gradient(90deg, #b6eae1 10%, #D2FBAD 90%);
}
.block-18 {
background: -webkit-linear-gradient(-90deg, #949494 10%, #efefef 90%);
background: linear-gradient(-90deg, #949494 10%, #efefef 90%);
}
.block-19 {
background: -webkit-linear-gradient(-90deg, #000000 50%, #eee 50%);
background: linear-gradient(-90deg, #000000 50%, #eee 50%);
}
.block-20 {
background: -webkit-linear-gradient(-45deg, #000 50%, #eee 50%);
background: linear-gradient(-45deg, #000 50%, #eee 50%);
}
.block-21 {
background: -webkit-linear-gradient(0deg, #949494 10%, #efefef 90%);
background: linear-gradient(0deg, #949494 10%, #efefef 90%);
}
.block-22 {
background: -webkit-linear-gradient(-45deg, #225e9e 0%, #712c69 100%);
background: linear-gradient(-45deg, #225e9e 0%, #712c69 100%);
}
.block-23 {
background-image: -webkit-radial-gradient(ellipse farthest-corner at center top, #9ab1c7 0%, #1a242f 100%);
background-image: radial-gradient(ellipse farthest-corner at center top, #9ab1c7 0%, #1a242f 100%);
}
.block-24 {
background: -webkit-linear-gradient(-45deg, #89ABE3 0%, #F2DDDE 100%);
background: linear-gradient(-45deg, #89ABE3 0%, #F2DDDE 100%);
}
.block-25 {
background-image: -webkit-linear-gradient(50deg, #abecd6 0%, #fbed96 100%);
background-image: linear-gradient(50deg, #abecd6 0%, #fbed96 100%);
}
.block-26 {
background-image: -webkit-linear-gradient(-60deg, #16a085 0%, #f4d03f 100%);
background-image: linear-gradient(-60deg, #16a085 0%, #f4d03f 100%);
}
.block-27 {
background-image: -webkit-linear-gradient(to top, #d5dee7 0%, #ffafbd 0%, #c9ffbf 100%);
background-image: linear-gradient(to top, #d5dee7 0%, #ffafbd 0%, #c9ffbf 100%);
}
.block-28 {
background-image: linear-gradient(to top, #df89b5 0%, #bfd9fe 100%);
background-image: linear-gradient(to top, #df89b5 0%, #bfd9fe 100%);
}
.block-29 {
background: -webkit-radial-gradient(#DC3D1F, #85210A);
background: radial-gradient(#DC3D1F, #85210A);
}
.block-30 {
background: -webkit-radial-gradient(#DB9561, #C55702);
background: radial-gradient(#DB9561, #C55702);
}
.block-31 {
background: linear-gradient(to left, #cc95c0 -25%, #dbd4b4, #7aa1d2 125%);
}
/* Layout stuff ---------------------------------------- */
* {
box-sizing: border-box;
}
body {
font-family: 'Josefin Sans', sans-serif;
background: #121212;
overflow-x: hidden;
}
.blocks {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
padding: 50px 0 100px;
}
.block {
-webkit-box-flex: 0;
-ms-flex: 0 0 350px;
flex: 0 0 350px;
height: 350px;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
color: white;
text-shadow: 1px 1px 0 rgba(0, 0, 0, 1);
margin: 15px;
border-radius: 6px;
cursor: pointer;
transition: 500ms;
}
.block.embiggen {
width: 100% !important;
height: 100% !important;
position: fixed;
left: 0;
top: 0;
right: 0;
bottom: 0;
margin: 0;
animation: scaleUp 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.9) both;
}
#output {
position: fixed;
left: 0px;
color: #fff;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
background: rgba(0, 0, 0, 0.3);
box-sizing: border-box;
font-weight: normal;
text-align: center;
bottom: 0px;
padding: 20px;
opacity: 0;
transition: all 1s;
z-index: -1;
}
#output.embiggen {
z-index: 1;
opacity: 1;
}
.click {
font-size: 1.2em;
color: rgba(255, 255, 255, .2);
position: absolute;
left: 20px;
top: -5px;
z-index: -1;
}
input {
position: absolute;
top: -100px;
}
label:after {
display: block;
position: fixed;
top: 15px;
right: 20px;
cursor: pointer;
font-family: FontAwesome;
font-style: normal;
font-weight: normal;
text-decoration: inherit;
color: #444;
font-size: 28px;
transition: 400ms;
}
label:hover:after {
color: #888;
}
.layout-1:after {
content: "\f009";
}
.layout-2:after {
content: "\f00a";
right: 55px;
}
.layout-3:after {
content: "";
top: 100px;
background: #444;
width: 28px;
height: 25px;
border-radius: 2px;
}
#grid:checked ~ .blocks .block {
flex: 0 1 350px;
height: 350px;
}
#list:checked ~ .blocks .block {
flex: 0 1 300px;
height: 80px;
}
@-webkit-keyframes scaleUp {
0% {
transform: scale(0);
}
100% {
transform: scale(1);
}
}
@keyframes scaleUp {
0% {
transform: scale(0);
}
100% {
transform: scale(1);
}
}
$(document).ready(function() {
$(".block").click(function() {
var newElement=$(this).eq(0).clone(true).appendTo(".blocks");
newElement.toggleClass("embiggen");
newElement.click(function() {
$(this).animate({
top: '-200vh'
},200);
setTimeout(function() {
$('.block:last-of-type').remove();
}, 0);
});
$("#output").toggleClass("embiggen");
var elem = this;
function getTheStyle() {
var theCSSprop = window
.getComputedStyle(elem, null)
.getPropertyValue("background-image");
document.getElementById("output").innerHTML =
"YOUR BROWSER RENDERED THIS: " + theCSSprop + ";";
}
getTheStyle();
});
});
Also see: Tab Triggers