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="container gutters-all">
<div class="col-11 col-push-half">
<h1 class="text-center">Juiced: Changing the Container Flow</h1>
<p>By adding the classes listed below to your <samp>.container</samp>, you can easily align, stretch, and position your flex items.</p>
<small>Note: these are based on a flex direction set to row (the Juiced default setting). Using another direction will change the flow.</small>
<h2 class="text-center alert">Item justification classes:</h2>
<ol>
<li>
<div class="text-left"> <samp>.justify-space-around</samp> adds spacing evenly around all Flex items.</div>
</li>
</ol>
<div class="container gutters items-center justify-space-around text-center" style="background:#f2f2f2;">
<div class="col-auto" style="background:#faa;">
items are spaced
</div>
<div class="col-auto" style="background:#b2a;">
.col-auto
</div>
<div class="col-auto" style="background:#af1;">
oh so pretty
</div>
</div>
<ol start="2">
<li>
<div class="text-left"> <samp>.justify-space-between</samp> adds spacing evenly between all Flex items.</div>
</li>
</ol>
<div class="container gutters items-center justify-space-between text-center" style="background:#f2f2f2;">
<div class="col-auto" style="background:#faa;">
items are spaced
</div>
<div class="col-auto" style="background:#b2a;">
.col-auto
</div>
<div class="col-auto" style="background:#af1;">
oh so pretty
</div>
</div>
<ol start="3">
<li>
<div class="text-left"><samp>.justify-start</samp> puts all the items in the start position.</div>
</li>
</ol>
<div class="container gutters items-center justify-start text-center" style="background:#f2f2f2;">
<div class="col-auto" style="background:#faa;">
items are spaced
</div>
<div class="col-auto" style="background:#b2a;">
.col-auto
</div>
<div class="col-auto" style="background:#af1;">
oh so pretty
</div>
</div>
<ol start="4">
<li>
<div class="text-left"> <samp>.justify-end</samp> moves the Flex items to sit at the end of the container.</div>
</li>
</ol>
<div class="container gutters items-center justify-end text-center" style="background:#f2f2f2;">
<div class="col-auto" style="background:#faa;">
push me to the end
</div>
<div class="col-auto" style="background:#b2a;">
.col-auto
</div>
<div class="col-auto" style="background:#af1;">
oh so pretty
</div>
</div>
<ol start="5">
<li>
<div class="text-left"><samp>.justify-center </samp> moves the items to sit in the center.</div>
</li>
</ol>
<div class="container gutters items-center justify-center text-center" style="background:#f2f2f2;">
<div class="col-auto" style="background:#faa;">
items are spaced
</div>
<div class="col-auto" style="background:#b2a;">
.col-auto
</div>
<div class="col-auto" style="background:#af1;">
oh so pretty
</div>
</div>
<h2 class="margin-top text-center">Vertical alignment classes:</h2>
<ol start="6">
<li>
<div class="text-left"><samp>.items-center</samp> will make vertical-centering a breeze!</div>
</li>
</ol>
<div class="container gutters items-center justify-center text-center" style="background:#f2f2f2;">
<div class="col-auto" style="background:#1aa; height: 50px">
<div class="container items-center" style="height: 50px;">
<div class="col-12">items</div>
</div>
</div>
<div class="col-auto" style="background:#bfa;">
Easy-peasy vertical centering
</div>
<div class="col-auto" style="background:#af1; height: 100px;">
oh so pretty
</div>
</div>
<ol start="7">
<li>
<div class="text-left"> <samp>.items-start</samp> forces the items to sit at the top of the container.</div>
</li>
</ol>
<div class="container gutters items-start justify-center text-center" style="background:#f2f2f2;">
<div class="col-auto" style="background:#faa; height:50px;">
items are spaced
</div>
<div class="col-auto" style="background:#b2a;">
I'm so fly at the top of my container!
</div>
<div class="col-auto" style="background:#af1;">
oh so pretty
</div>
</div>
<ol start="8">
<li>
<div class="text-left"> <samp>.items-end</samp> forces the items to sit at the bottom of the container.</div>
</li>
</ol>
<div class="container gutters items-end justify-center text-center" style="background:#f2f2f2;">
<div class="col-auto" style="background:#faa; height:50px;">
items are spaced
</div>
<div class="col-auto" style="background:#b2a;">
I sit on the bottom
</div>
<div class="col-auto" style="background:#af1;">
And that's okay
</div>
</div>
<ol start="9">
<li>
<div class="text-left"> <samp>.items-stretch</samp> forces all items to stretch to the height of the container.</div>
</li>
</ol>
<div class="container gutters items-stretch justify-center text-center" style="background:#f2f2f2; height:50px;">
<div class="col-auto" style="background:#faa;">
items are spaced
</div>
<div class="col-auto" style="background:#b2a;">
I am stretchy
</div>
<div class="col-auto" style="background:#af1;">
And that's okay
</div>
</div>
<ol start="10">
<li>
<div class="text-left"> <samp>.items-baseline</samp> causes the items to sit on their baseline.</div>
</li>
</ol>
<div class="container gutters items-baseline justify-center text-center" style="background:#f2f2f2; height: 100px;">
<div class="col-sm-4" style="background:#faa; ">
A margin on one item, will shift the others to match the baseline.
<div class="sm-display-none color-dark">
(<small>Not so noticable when on mobile, as the baseline is no longer applicable when columns collapase</small>)
</div>
</div>
<div class="col-sm-4" style="background:#b2a;">
I sit with my friends
</div>
<div class="col-sm-4" style="background:#af1; margin-top: 15px;">
We sit on the baseline
</div>
</div>
</div>
.margin-top{
margin-top:50px;
}
ol {
margin-top: 40px;
}
Also see: Tab Triggers