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 class="panel"><h3>Playing with CSS columns</h3>
<label>column-count</label>
<input type="range" min="1" max="15" class="updater" data-change="column-count" value="6" />
<label>column-gap </label>
<input type="range" min="0" max="40" step=".1" class="updater" data-change="column-gap" value="22" />
<select class="updater column-gap-unit" data-change="column-gap">
<option>em</option>
<option>mm</option>
<option>vw</option>
<option selected="selected">px</option>
</select>
<label>column-rule-width</label>
<input type="range" min="0" max="40" class="updater" data-change="column-rule-width" value="3" />
<select class="updater column-rule-width-unit" data-change="column-rule-width">
<option>em</option>
<option>mm</option>
<option>vw</option>
<option selected="selected">px</option>
</select>
<label>column-rule-style</label>
<select class="updater" data-change="column-rule-style">
<option>dashed</option>
<option selected="selected">double</option>
<option>dotted</option>
<option>groove</option>
<option>solid</option>
</select>
<label>column-break-before</label>
<select class="updater" data-target=".header" data-change="column-break-before">
<option>auto</option>
<option selected="selected">initial</option>
<option>always</option>
<option>avoid</option>
<option>left</option>
<option>right</option>
<option>recto</option>
</select>
<select class="dummyImageProvider">
<option value="http://lorempixel.com/%w%/%h%">lorempixel.com</option>
<option value="http://dummyimage.com/%w%x%h%">dummyimage.com</option>
<option value="http://lorempizza.com/%w%x%h%">lorempizza.com</option>
<option value="http://placekitten.com/%w%/%h%">placekitten.com</option>
<option value="http://placebeyonce.com/%w%-%h%">Boyonce</option>
<option selected="selected" value="http://placebeard.it/%w%/%h%/notag">placebeard.it</option>
</select>
</div>
<div class="title"><h1>CSS based columns </h1><small>P.s.: You may edit the dummy content</small></div>
<pre>CSS: <div class="css"></div></pre>
<div class="output" contenteditable="true">
</div>
<!-- UNDER CONSTRUNCTION START -->
<div id="banner"><a href="">Updated 11/9/15</a></div>
<style type="text/css">
/* RELATED TO UNDER CONSTRUCTION ONLY */
#banner{
height: 149px;
width: 149px;
overflow:hidden;
padding: 0;
margin: 0;
position: fixed;
right: 0px;
top: 0px;
}
#banner a{
display: block;
width: 200px;
font-size: 14px;
font-family: Frutiger, "Frutiger Linotype", Univers, Calibri, "Gill Sans", "Gill Sans MT",
"Myriad Pro", Myriad, "DejaVu Sans Condensed", "Liberation Sans", "Nimbus Sans L", Tahoma,
Geneva, "Helvetica Neue", Helvetica, Arial, sans serif;
background-color: #333;
color: #FFF;
word-spacing: 2px;
text-decoration: none;
padding: 5px 15px 5px 25px;
position:relative;
left: 20px;
top: -37px;
text-align: center;
-moz-transform-origin: 0 0 ;
-moz-transform:rotate(45deg);
-moz-box-shadow: 1px 1px 5px 1px #666;
-webkit-transform-origin: 0 0 ;
-webkit-transform:rotate(45deg);
-webkit-box-shadow: 1px 1px 5px 1px #666;
-ms-transform-origin: 0 0 ;
-ms-transform:rotate(45deg);
-ms-box-shadow: 1px 1px 5px 1px #666;
transform-origin: 0 0 ;
transform:rotate(45deg);
box-shadow: 1px 1px 5px 1px #666;
background-image: linear-gradient(bottom, #000000 3%, #666666 5%, #000000 7%, #000000 93%, #666666 95%, #000000 97%);
background-image: -o-linear-gradient(bottom, #000000 3%, #666666 5%, #000000 7%, #000000 93%, #666666 95%, #000000 97%);
background-image: -moz-linear-gradient(bottom, #000000 3%, #666666 5%, #000000 7%, #000000 93%, #666666 95%, #000000 97%);
background-image: -webkit-linear-gradient(bottom, #000000 3%, #666666 5%, #000000 7%, #000000 93%, #666666 95%, #000000 97%);
background-image: -ms-linear-gradient(bottom, #000000 3%, #666666 5%, #000000 7%, #000000 93%, #666666 95%, #000000 97%);
background-image: -webkit-gradient(
linear,
left bottom,
left top,
color-stop(0.03, #000000),
color-stop(0.05, #666666),
color-stop(0.07, #000000),
color-stop(0.93, #000000),
color-stop(0.95, #666666),
color-stop(0.97, #000000)
);
}
</style>
<!-- UNDER CONSTRUNCTION END -->
@import url(https://fonts.googleapis.com/css?family=Inconsolata:400,700|Open+Sans:400,800);
body {
font-family: 'Open Sans', sans-serif;
font-size: 90%;
padding: 0 10px;
margin: 0;
}
.panel {
opacity: .84;
position: fixed;
bottom: 0;
left: 0;
box-shadow: 0 0 10px black;
z-index: 2;
background: rgba(255, 255, 255, .93);
width: 100%;
padding: 6px;
transition: all .4s .2s;
}
.panel:hover {
opacity: 1;
bottom: 0;
transition: all .4s .1s;
}
.panel h3 {
color: #009;
margin: 0 0 5px;
display: inline-block;
border-right: solid 2px #00a;
padding-right: 5px;
}
.panel label,
.css {
font-family: 'Inconsolata', monospace;
}
.output {
column-rule: 1px solid #ccc;
column-fill: auto;
column-count: 6;
font-size: 80%;
column-width: auto;
column-gap: 2em;
height: 400px;
}
.output img {
width: 80%;
max-height: 100px;
margin: 10px 20% 5px 0%;
max-width: 400px;
}
.header:first-letter {
text-transform: uppercase;
}
.header {
margin-top: 0;}
pre {
font-weight: bold;
font-size: 12pt;
}
.css {
display: inline;
font-size: smaller;
}
.css span {
padding-right: .5em;
font-weight: normal;
}
h1, h2, h3, h4, h5, h6 {
color: #222;
}
.title * {
display: inline-block;
height: .25em;
}
.title small {
margin-left: 1em;
}
var dummyImageProvider = "";
$(function() {
getBaconIpsum();
dummyImageProvider = $(".dummyImageProvider").val();
$(".dummyImageProvider").on("change", function() {
dummyImageProvider = $(".dummyImageProvider").val();
getBaconIpsum();
});
$(".panel").on("change touchend touchstart", setValues);
setValues();
});
function setValues() {
var css = "";
$(".updater").each(function() {
var $this = $(this);
var property = $this.data("change");
if (typeof property !== "undefined") {
var target = $this.data("target") || ".output";
var unit = $("." + property + "-unit").val() || "";
var prop = PrefixFree.prefixProperty(property);
if (this.value != unit) {
var val = this.value + unit;
css += "<span>" + prop + ": " + val + ";</span>";
$(target).css(prop, val);
}
}
});
$(".css").html(css);
}
function getBaconIpsum() {
$.getJSON('https://baconipsum.com/api/?callback=?', {
'type': ((Math.random() > .5) ? 'meat-and-filler' : 'all-meat'),
'start-with-lorem': '1',
'paras': '15'
},
function(baconGoodness) {
if (baconGoodness && baconGoodness.length > 0) {
$(".output").html('');
for (var i = 0; i < baconGoodness.length; i++) {
var sHeader = "";
if (Math.random() > .4 || i === 0) {
var htype = parseInt(Math.random() * 4) + 1;
var header = baconGoodness[i].split(" ");
var noOfWords = parseInt(Math.random() * 10) + 2;
var wStart = parseInt(Math.random() * (header.length - noOfWords));
sHeader = "<h" + htype + " class=\"header\">";
for (var ii = wStart; ii < wStart + noOfWords; ii++) {
sHeader += header[ii].replace(/[\.,]/ig, "") + " ";
};
sHeader += "</h" + htype + ">";
}
var text = baconGoodness[i].split(" ");
text = addImage(text).join(" ");
$(".output").append(sHeader + '<p>' + text + '</p>');
}
}
});
}
function addImage(arr) {
var width = parseInt(Math.random() * 6) * 40 + 80;
var height = parseInt(Math.random() * 6) * 40 + 40;
var errSrc = "http://dummyimage.com/"+width+"/"+height+"/";
var src = ("<img src='"+dummyImageProvider+"' style=\"min-width: %w%px; min-height: %h%px\" onerror=\"src=\'"+errSrc+"\'\" />").replace(/%w%/g, width).replace(/%h%/g, height);
arr.splice(Math.random() * arr.length, 0, src);
return arr;
}
Also see: Tab Triggers