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.
<header>
<h1>CSS Grid Poster</h1>
<p><a href="//caniuse.com/#feat=css-grid" target="_blank" title="CSS Grid Layout Module Level 1">CSS Grids</a> are coming – this is my first take</p>
</header>
// Not a big fan of jade, haml or their evil twins
// just too d... lazy to copy paste 77 divs ;)
.grid
- for (var x = 0; x < 77; x++)
div
<footer>
<p>If you <strong>don't see anything</strong> – please enable:<br> <a href="chrome://flags/#enable-experimental-web-platform-features" target="_blank">chrome://flags/#enable-experimental-web-platform-features</a><br>or maybe try <a href="//www.mozilla.org/en-US/firefox/developer/">Firefox for developers (v.46)</a></p>
<p>Poster design by <a href="//www.connect.ecuad.ca/people/work/249835" target="_blank">Yumi Simonson</a></p>
</footer>
html {box-sizing:border-box;}
*,*:before,*:after{box-sizing:inherit;}
body {margin:0; padding:0 10vmin;}
@support (display: grid) {
h1 { color:orange !important;}
}
.grid {
display: grid;
// Fractions does not seem to play well with Firefox :(
// Please let me know if I'm wrong
// grid-template-columns: repeat(191, 1fr);
// grid-template-rows: repeat(250, 1fr);
// 520px/191 = 2.722513089px
grid-template-columns: repeat(191, 2.722513089px);
grid-template-rows: repeat(250, 2.722513089px);
@media (max-width:640px){
grid-template-columns: repeat(191, 80/191 * 1vmin);
grid-template-rows: repeat(250, 100/250 * 1vmin);
}
width:100%;
max-width:520px;
margin:0 auto;
&:before,&:after {content:'';display:table; }
&:before {float:left; padding-bottom:100%}
&:after {clear:both;}
& >div {
&:not(:last-of-type){ background-color: #666; }
animation:animate .5s forwards;
opacity:0; transform: scale(0.1) rotate(-180deg);
cursor:pointer;
transition:all .3s;
counter-increment: cellcount;
position:relative;
// Show cell number on hover
&:hover {
z-index:1;
background-color:#282828;
background-color:#b90000;
&:before {
content:counter(cellcount);
font-size:9px;
font-family:sans-serif;
padding:4px;
position:absolute;
display:block;
background-color:#b90000;
color:#fff;
font-weight:700
}
}
// Spinning top
&:last-of-type {
background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 44.4 53'%3E %3Cpath fill='%23666' d='M33.5 27.9c-.6-3.4 10.3-24.8 10.8-25.7.5-.9-.7-2-.7-2s-1.3-.6-2 .2-16.1 19.2-19.5 19.9C10.2 23 1.3 16.5.2 18.1c-1.4 2.1 3.7 9.1 6.8 12.1 2.4 3.8 1.7 8.1 1.2 10.1-3 9.9.7 12.1.7 12.1s3.5 2.5 11.5-4c1.7-1.2 5.4-3.4 9.8-2.7 4 1.7 12.4 3.7 13.8 1.6 1.1-1.7-8.4-7.4-10.5-19.4z'/%3E %3C/svg%3E");
background-repeat:no-repeat;
}
}
}
@keyframes animate {
to {opacity:1; transform: scale(1) rotate(0deg);}
}
$areas:(
//
// The order of the values is row-start/column-start/row-end/column-end.
// ... but (while learning) I prefer the x/y/w/h
// x y w h
15 10 3 18, // I
23 10 3 18, // N
27 10 13 3,
37 14 3 14,
45 10 3 14, // C
49 10 13 3,
45 25 17 3,
67 10 17 3, // E
67 14 3 14,
71 18 8 3,
71 25 13 3,
89 10 17 3, // P
89 14 3 14,
93 18 13 3,
103 14 3 3,
110 10 18 3, // T
118 14 3 14,
133 10 3 18, // I
141 10 17 3, // O
141 14 3 14,
145 25 13 3,
155 14 3 10,
163 10 3 18, // N
167 10 13 3,
177 14 3 14,
// Blocks
1 41 83 37,
86 41 12 77,
86 119 12 3,
86 122 40 23,
102 41 24 79,
131 41 62 32,
1 79 14 5,
16 79 10 5,
27 79 14 5,
1 86 40 37,
43 79 14 31,
58 79 3 31,
62 79 2 31,
65 79 3 31,
69 79 2 31,
72 86 12 24,
1 125 27 79,
1 207 27 44,
28 226 34 25,
31 124 26 15,
31 141 38 4,
31 147 38 48,
131 76 62 32,
131 110 2 18,
134 110 2 18,
138 108 22 32,
161 110 31 4,
161 121 31 2,
168 125 24 80,
138 143 27 5,
138 149 27 9,
138 160 27 4,
138 166 27 4,
138 172 27 4,
138 178 27 9,
138 188 27 17,
149 208 43 43,
131 208 14 43,
92 223 37 28,
92 214 29 9,
92 198 15 16,
71 180 26 9,
71 190 26 5,
83 198 6 53,
76 198 5 53,
73 198 2 53,
66 198 4 53,
60 198 4 25,
54 198 4 25,
49 198 4 25,
32 198 4 25,
115 193 12 13
);
@function area($index){
@return #{
nth(nth($areas, $index),2)'/'
nth(nth($areas, $index),1)'/'
nth(nth($areas, $index),4) + nth(nth($areas, $index),2)'/'
nth(nth($areas, $index),3) + nth(nth($areas, $index),1)
}
}
@for $i from 1 through length($areas){
.grid > div:nth-of-type(#{$i}){
grid-area: area($i);
animation-delay: $i*0.05s + 1s;
}
}
header { border-bottom:1px solid silver;text-align: center; }
footer { border-top:1px solid silver;}
footer,header { display:block; margin:40px auto; max-width:640px;}
h1,p,a {
font-family:sans-serif; font-size:12px; text-transform:uppercase;
color:#666;
text-decoration:none;
}
a {font-weight:700; border-bottom:1px dashed silver; }
img { width:10vmin; float:left;}
footer p:last-of-type {text-align:right;}
h1 { font-family:monospace;font-size:24px; line-height:1.4; font-weight:400; margin:20px 0; text-align:center; border-bottom:1px solid silver; }
p { font-size:11px; line-height:1.7; }
a[href*=chrome],a[href*="//www.mozilla"] { font-size:11px; font-weight:400; text-transform:none; }
p strong {color:#b90000;}
h1 strong { font-weight:400; }
Also see: Tab Triggers