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.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>OSTraining - Create a Column Pattern with Flexbox</title>
<link rel="stylesheet" href="style.css">
<link href="https://fonts.googleapis.com/css?family=Playfair+Display|Raleway|Roboto+Condensed|Roboto+Slab:400,700&display=swap" rel="stylesheet">
</head>
<body>
<div class="header-container">
<header class="header two-columns">
<div class="blog-name"><h1>My Blog</h1></div>
<div class="menu"><ul>
<li><a href="#">Me</a></li>
<li><a href="#">You</a></li>
<li><a href="#">Blog</a></li>
<li><a href="#">About</a></li>
</ul></div>
</header>
</div>
<div class="outer-wrapper">
<div class="container">
<!-- One Column - Image + Text -->
<div class="one-column">
<img src="http://lorempixel.com/750/465/abstract/1" alt="Example Image">
<h2>Yet Another Flexbox Blog</h2>
<p>They're creepy and they're kooky mysterious and spooky. They're all together ooky the Addams Family. All of them had hair of gold like their mother the youngest one in curls.</p>
</div>
<!-- Two Columns - Image + Text -->
<div class="two-columns">
<img src="http://lorempixel.com/500/310/abstract/2" alt="Example Image">
<div class="text-container">
<h3>Lorem ipsum dolor sit amet.</h3>
<p>The year is 1987 and NASA launches the last of Americas deep space probes. Makin' your way in the world today takes everything you've got. Takin' a break from all your worries sure would help a lot. Today still wanted by the government they survive as soldiers of fortune. The year is 1987 and NASA launches the last of Americas deep space probes.</p>
</div>
</div>
<!-- Three Columns - Nested Columns -->
<div class="three-columns">
<img src="http://lorempixel.com/500/310/abstract/3" alt="Example Image">
<div class="text-container">
<h3>Lorem ipsum dolor sit amet.</h3>
<p>Go Speed Racer. Go Speed Racer. Go Speed Racer go! Doin' it our way. Nothin's gonna turn us back now. Straight ahead and on the track now. We're gonna make our dreams come true.</p>
</div>
<div class="nested">
<h3>Lorem ipsum dolor sit.</h3>
<p>The movie star the professor and Mary Ann here on Gilligans Isle</p>
<div class="two-columns">
<img src="http://lorempixel.com/500/310/abstract/4" alt="Example Image">
<p>In a freak mishap Ranger 3 and its pilot Captain William Buck Rogers are blown out of their trajectory into an orbit which freezes his life support systems and returns Buck Rogers to Earth five-hundred years later.</p>
</div>
</div>
</div>
<!-- Four Columns - Card Container -->
<div class="four-columns">
<div class="card-container">
<div class="one-column">
<img src="http://lorempixel.com/250/155/abstract/5" alt="Example Image">
<h3>Lorem ipsum dolor sit.</h3>
<p>It's time to put on makeup. It's time to dress up right. It's time to raise the curtain on the Muppet Show tonight</p>
<ul>
<li>alpha</li>
<li>beta</li>
<li>gamma</li>
<li>delta</li>
</ul>
</div>
</div>
<div class="card-container">
<div class="one-column">
<img src="http://lorempixel.com/250/155/abstract/6" alt="Example Image">
<h3>Lorem ipsum dolor sit.</h3>
<p>It's time to put on makeup. It's time to dress up right. It's time to raise the curtain on the Muppet Show tonight</p>
<ul>
<li>alpha</li>
<li>beta</li>
<li>gamma</li>
<li>delta</li>
</ul>
</div>
</div>
<div class="card-container">
<div class="one-column">
<img src="http://lorempixel.com/250/155/abstract/7" alt="Example Image">
<h3>Lorem ipsum dolor sit.</h3>
<p>It's time to put on makeup. It's time to dress up right. It's time to raise the curtain on the Muppet Show tonight</p>
<ul>
<li>alpha</li>
<li>beta</li>
<li>gamma</li>
<li>delta</li>
</ul>
</div>
</div>
<div class="card-container">
<div class="one-column">
<img src="http://lorempixel.com/250/155/abstract/8" alt="Example Image">
<h3>Lorem ipsum dolor sit.</h3>
<p>It's time to put on makeup. It's time to dress up right. It's time to raise the curtain on the Muppet Show tonight</p>
<ul>
<li>alpha</li>
<li>beta</li>
<li>gamma</li>
<li>delta</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
html {
box-sizing: border-box;
font-size: 16px;
}
*, *:before, *:after {
box-sizing: inherit;
}
body, h1, h2, h3, h4, h5, h6, p, ol, ul {
margin: 0;
padding: 0;
font-family: 'Raleway', sans-serif;
font-weight: normal;
}
ol, ul {
list-style: none;
}
.container,
.one-column,
.two-columns,
.three-columns,
.four-columns {
display: flex;
flex-wrap: wrap;
}
.container > * { /* Target only the direct children of .container */
margin: 1em 4%;
}
.one-column > * { /* Target only the direct children of .one-column */
flex: 1 0 92%;
}
.two-columns > * {
flex: 1 0 46%;
}
.three-columns > * {
flex: 1 0 23%;
}
.four-columns > * {
flex: 1 0 11.5%;
}
.menu ul {
display: flex;
justify-content: space-evenly;
}
.container > img,
.container > * > img,
.container > * > * > img,
.container > * > * > * > img {
flex-grow: 0;
display: block;
max-width: 100%;
height: auto;
margin: 0 auto;
}
p,
ul,
img {
padding: 8px 12px;
}
h2,
h3 {
padding-left: 8px;
}
.outer-wrapper {
width: 1000px;
margin: 0 auto;
}
.container {
width: 90%;
margin: 0 auto;
}
/* Header Section */
/* Making the header container stay always on top + border + min-height => this height
* has to be compensated with margin on top of the next block level element (sibling)
* ==> .outer-wrapper + shadow
**/
.header-container {
background-color: rgb(236, 236, 236);
border-bottom: 0.5em double #2e2e2e;
position: fixed;
top: 0;
left: 0;
z-index: 10;
width: 100vw;
min-height: 75px;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
.outer-wrapper {
margin-top: 75px;
z-index: 5;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
/* Align items vertically on the .header section */
.header {
display: flex;
align-items: baseline;
padding-top: 0.5em;
}
.header h1 {
padding-left: 25%;
font-family: 'Playfair Display', serif;
font-size: 2.5em;
font-weight: bold;
}
.header a {
text-decoration: none;
font-family: 'Roboto Slab', serif;
text-transform: uppercase;
color: #2e2e2e;
}
body,
p,
ol,
ul {
font-family: 'Raleway', sans-serif;
color: #1f1f1f;
}
.container h1,
.container h2,
.container h3,
.container h4,
.container h5,
.container h6 {
font-family: 'Playfair Display', serif;
text-decoration: underline;
color: #1d1d1d;
}
Also see: Tab Triggers