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.
.page
article
header.header
h1
span.jumbo 6
span.sign
span.sign__text brands
span.subjumbo for the summer
section.section
h2.section__title
span.section__innertitle The inner workings
p
| The first step was to find a font which had a number ‘6’ that was almost perfectly circular. The font of choice in this case is Lato.
| The next step is to make the image fit inside the number. The trick is to pick an image and add it as a background-image of the number. The sizing is relatively easy by setting the background-size in em value. The positioning is trial–and–error, but doable.
| Another trick is to give the <h1> a viewport-relative font-size and style the inner elements (the ‘6’, ‘brands’ and ‘for the summer’) with relative units, like ems, so they will always scale with the size of the title.
| (The font-sizes aren't bullet proof on large screens, but you get the idea)
footer.footer
small
| Another
a href='https://codepen.io/search/pens?q=magazine+layout&limit=all&type=type-pens' magazine layout
| brought to you by
a href='https://codepen.io/bartveneman' a dude who likes to bring magazine layouts to the web
| . Image taken from
a href="https://unsplash.com/photos/RunDjvjvtoI" Unsplash
// SETTINGS
$primary: #333
$secondary: #fff
$cta: tomato
=mq
@media (min-width: 48em)
@content
// TYPOGRAPHY
@import 'https://fonts.googleapis.com/css?family=Lato:300,400,700'
html
font: 400 1em/1.4 'Lato', sans-serif
color: $primary
-webkit-font-smoothing: antialiased
h1
margin: 0 0 16rem
text-transform: uppercase
text-align: center
// Set a viewport-relative font-size once for the whole
// <h1>. Child elements will be sized using em's, so they
// will scale with this element regardlessof it's font-size
font-size: calc(55vh + 55vw)
.jumbo
display: block
margin: -0.25em 0 0 // move up a little
line-height: 0.875
font-weight: 300
background-image: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/5175/photo-1452117774045-dfd7a5e9718c.jpeg')
background-repeat: no-repeat
// Trial-and error positioning and sizing
background-size: 0.39em auto
background-position: 53% 87.5%
.sign
display: block
font-size: 0.125em
margin: -3.2em 0 0 // tweak position to it's inside the '6'
.sign__text
background-color: $primary
color: $secondary
display: inline-block
padding: 0 0.3em 0.1em
line-height: 1
position: relative
margin: 0 0 0.45em
// Generate the bottom border which is slightly wider
// than the text
&::before
content: ''
position: absolute
bottom: 0.08em
border-top: 0.04em solid
left: 0.2em
right: 0.2em
// Had a hard time coming up with proper classnames here...
.subjumbo
display: block
text-decoration: underline
font-size: 0.03em
text-shadow: 0.07em 0.05em 0 $secondary
.section
p
line-height: 1.5
+mq
column-count: 2
column-gap: 1em
line-height: 1.33 // shorter lines of text, so lower line-height
// Not too happy with this technique: place an inline-block
// element inside a block element to get the bottom-border
// to be the right width (like an underline)
.section__title
text-align: center
font-size: 1.15em
.section__innertitle
text-transform: uppercase
font-weight: 400
border-bottom: 0.15em solid
a
color: $cta
// LAYOUT
html
background: $secondary
body
margin: 0
+mq
padding: 1em
.page
padding: 1em
margin: 1em
border: 1px solid
max-width: 44em
+mq
padding: 3em 5em
margin-right: auto
margin-left: auto
.footer
margin-top: 3em
text-align: center
Also see: Tab Triggers