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="magazine">
<!-- 区域1 -->
<div class="item green">
<div class="subtitle">featured article</div>
<h1>Divinity: Original Sin 2</h1>
</div>
<!-- 区域2 -->
<div class="item blue">
<h2>the best table top minus the table</h2>
<div class="submit">by fraser brown</div>
<p>
Bacon ipsum dolor amet cupim buffalo shankle, ham fatback turducken drumstick sirloin. Jowl buffalo venison shank pork belly alcatra, tenderloin bacon ribeye picanha spare ribs fatback ham hock. Sirloin pork pancetta, landjaeger ham hock biltong meatloaf
brisket shoulder. Filet mignon ground round chuck turkey rump capicola.
</p>
<p>
Flank fatback bacon jerky picanha brisket ball tip cupim. Jerky fatback shankle andouille picanha cupim pancetta pork chop tongue corned beef pork loin ham hock rump tri-tip t-bone. Meatball turducken burgdoggen cupim salami bresaola. Boudin turkey bresaola,
short ribs ribeye short loin meatloaf corned beef picanha t-bone. Fatback beef cupim pork chop.
</p>
<p>
Tail short loin tenderloin turducken. Pancetta bacon beef ribs turducken leberkas. Biltong kevin buffalo porchetta, chicken meatloaf doner chuck sirloin shankle swine. Boudin bacon chicken, cupim filet mignon salami venison chuck tongue ham tenderloin
cow.
Chuck doner ham, chicken burgdoggen jerky short ribs picanha rump tenderloin ground round boudin cow shoulder beef.
</p>
<p>
Doner ribeye flank shankle bacon. Alcatra shoulder buffalo cow short loin shankle. Chicken chuck beef rump pork chop pork belly pork loin leberkas filet mignon kielbasa meatloaf andouille meatball. Burgdoggen sausage hamburger, drumstick prosciutto meatball
buffalo pork belly ground round shoulder. Brisket filet mignon meatloaf, shankle salami jerky flank pig kevin porchetta sirloin. Brisket meatloaf andouille burgdoggen sirloin pancetta. Burgdoggen capicola leberkas picanha tail.
</p>
</div>
<!-- 区域3 -->
<div class="item purple">
<p>
Bacon ipsum dolor amet cupim buffalo shankle, ham fatback turducken drumstick sirloin. Jowl buffalo venison shank pork belly alcatra, tenderloin bacon ribeye picanha spare ribs fatback ham hock. Sirloin pork pancetta, landjaeger ham hock biltong meatloaf
brisket shoulder. Filet mignon ground round chuck turkey rump capicola.
</p>
<p>
Flank fatback bacon jerky picanha brisket ball tip cupim. Jerky fatback shankle andouille picanha cupim pancetta pork chop tongue corned beef pork loin ham hock rump tri-tip t-bone. Meatball turducken burgdoggen cupim salami bresaola. Boudin turkey bresaola,
short ribs ribeye short loin meatloaf corned beef picanha t-bone. Fatback beef cupim pork chop.
</p>
</div>
<!-- 区域4 -->
<div class="item orange">
<h4>score: 92</h4>
<ul>
<li>compelling story</li>
<li>entertaining co-op</li>
<li>innovative 'gm mode'</li>
</ul>
</div>
<!-- 区域5 -->
<div class="item meired">
<figure>
<img src="https://picsum.photos/1386/1013?random=1" alt="">
</figure>
</div>
<!-- 区域6 -->
<div class="item black">
<p>We both died. Twice. But I still felt really good about my decision.</p>
</div>
</div>
@import url("https://fonts.googleapis.com/css2?family=Exo:wght@600&display=swap");
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
figure {
margin: 0;
}
body {
width: 100vw;
min-height: 100vh;
font-family: "Exo", Arial, sans-serif;
background-color: #f7f7f7;
display: flex;
justify-content: center;
align-items: center;
}
.magazine {
width: 95vw;
display: grid;
grid-template-rows: 130px 2fr 1fr;
grid-template-columns: 1.5fr 1fr 1fr 1.5fr;
}
.green {
grid-row: 1;
grid-column: 1 / 3;
z-index: 1;
background: #f4d434;
color: black;
justify-content: start;
align-items: end;
text-transform: uppercase;
font-weight: bold;
font-size: calc(10px + 2.6vw);
padding-left: 20px;
display: grid;
}
.subtitle {
font-size: calc(10px + 0.6vw);
}
.green h1 {
margin: 0 0 0.5vw;
font-size: inherit;
}
.blue {
grid-row: 2 / 4;
grid-column: 1 / 2;
overflow: hidden;
padding: 10px 20px;
font-size: 14px;
}
.blue h2 {
font-size: calc(10px + 0.8vw);
magin-bottom: 10px;
text-transform: uppercase;
}
.blue p {
font-size: 14px;
margin-bottom: 1rem;
line-height: 1.5;
}
.submit {
text-transform: uppercase;
margin-bottom: 20px;
margin-top: 10px;
}
.purple {
grid-row: 3 / 4;
grid-column: 2 / 4;
overflow: hidden;
display: grid;
grid-template-columns: 1fr 1fr;
grid-column-gap: 30px;
align-items: start;
padding: 10px 20px;
font-size: 14px;
}
.purple p {
font-size: 14px;
margin-bottom: 1rem;
line-height: 1.5;
}
.black {
grid-row: 2;
grid-column: 4;
z-index: 2;
background: rgba(0, 0, 0, 0.5);
align-self: end;
justify-self: start;
position: relative;
color: #e5d54f;
border-left: 10px solid #e5d54f;
padding: 10px;
right: 125px;
bottom: 6%;
text-transform: uppercase;
font-size: calc(12px + 1.1vw);
}
.meired {
grid-row: 1 / 3;
grid-column: 2 / 5;
}
.orange {
grid-row: 3;
background: #f4d434;
width: 70%;
height: 70%;
display: flex;
align-items: flex-start;
justify-content: flex-start;
flex-direction: column;
padding: 5px;
font-size: calc(12px + 2.6vw);
font-weight: bold;
text-transform: uppercase;
}
.orange h4 {
font-size: calc(10px + 2.6vw);
margin-bottom: 1.5rem;
}
.orange ul {
list-style: none outside none;
font-size: calc(10px + 0.6vw);
}
.orange li {
display: flex;
align-items: center;
gap: 5px;
}
.orange li:not(:last-child) {
margin-bottom: 1rem;
}
.orange li::before {
content: "";
display: block;
width: 20px;
aspect-ratio: 16 / 9;
background-color: currentColor;
margin-left: -15px;
}
figure {
margin: 0;
width: 100%;
height: 100%;
}
figure img {
width: 100%;
height: 100%;
object-fit: cover;
object-position: center;
}
Also see: Tab Triggers