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="wrapper">
<nav>
ナビゲーションエリア
</nav>
<main class="main">
<h2>メインエリア</h2>
<div class="tweet">
<p>よく晴れた気持ちのいい朝。飼い猫の💩の強烈なかほりで私の目は覚めた。ふと見ると、彼はらんらんとした瞳で私を見つめ、彼の創造物を片付けることを期待していた。</p>
<div class="reaction-bar">
<div class="reaction">
<button class="material-symbols-rounded">chat_bubble</button>
<span class="text">返信する</span>
<span class="count">60</span>
</div>
<div class="reaction">
<button class="material-symbols-rounded">favorite</button>
<span class="text">いいね</span>
<span class="count">120</span>
</div>
<div class="reaction">
<button class="material-symbols-rounded">bar_chart</button>
<span class="text">View数</span>
<span class="count">1.2K</span>
</div>
<div class="reaction">
<button class="material-symbols-rounded">share</button>
<span class="text">シェアする</span>
</div>
</div>
</div>
<section>
<h3>1カラム・2カラムが切り替わるエリア</h3>
<div class="section-inner">
<div class="tweet">
<p>「やれやれ…」私は立ち上がり、スコップを手に取る。そう、私は"Splendid cleaner of cat creations"(猫の創造物の華麗な掃除屋)。今日も我が家の秩序のために闘うのだ。</p>
<div class="reaction-bar">
<div class="reaction">
<button class="material-symbols-rounded">chat_bubble</button>
<span class="text">返信する</span>
<span class="count">12</span>
</div>
<div class="reaction">
<button class="material-symbols-rounded">favorite</button>
<span class="text">いいね</span>
<span class="count">30</span>
</div>
<div class="reaction">
<button class="material-symbols-rounded">bar_chart</button>
<span class="text">View数</span>
<span class="count">980</span>
</div>
<div class="reaction">
<button class="material-symbols-rounded">share</button>
<span class="text">シェアする</span>
</div>
</div>
</div>
<div class="tweet">
<p>その創造物は想像を超えていたーーー。まるでジャック・ライアンがスレイマンに追い詰められ、右手の手榴弾のピンを外したときのように、私の緊張感は最高潮に達していた。</p>
<div class="reaction-bar">
<div class="reaction">
<button class="material-symbols-rounded">chat_bubble</button>
<span class="text">返信する</span>
<span class="count">10.4K</span>
</div>
<div class="reaction">
<button class="material-symbols-rounded">favorite</button>
<span class="text">いいね</span>
<span class="count">120</span>
</div>
<div class="reaction">
<button class="material-symbols-rounded">bar_chart</button>
<span class="text">View数</span>
<span class="count">20K</span>
</div>
<div class="reaction">
<button class="material-symbols-rounded">share</button>
<span class="text">シェアする</span>
</div>
</div>
</div>
</div>
</section>
</main>
</div>
.reaction-bar {
container-type: inline-size;
}
@container (max-width: 560px) {
.reaction-bar .text {
display: none;
}
}
/* その他のスタイル */
:root {
--main-color: 139, 152, 165;
--padding: 16px;
}
body {
font-family: "游ゴシック Medium", YuGothic, YuGothicM,
"Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
line-height: 1.7;
color: rgb(var(--main-color));
background-color: rgb(32, 43, 54);
}
.material-symbols-rounded {
color: currentColor;
font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 48;
}
.wrapper {
display: grid;
align-content: start;
height: calc(100svh - 16px * 2);
padding: var(--padding);
grid-template:
"nav main" 1fr /
200px 1fr;
}
@media (max-width: 650px) {
.wrapper {
grid-template:
"nav" auto
"main" auto
/ 1fr;
}
}
nav {
display: grid;
background-color: rgba(var(--main-color), 0.2);
writing-mode: vertical-rl;
place-content: center;
}
@media (max-width: 650px) {
nav {
height: 70px;
writing-mode: horizontal-tb;
}
}
.main {
padding: var(--padding);
}
.section-inner {
display: grid;
gap: 16px;
grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
}
.section-inner > .tweet {
padding: var(--padding);
border: 1px solid rgba(var(--main-color), 0.3);
border-radius: 3px;
}
.reaction-bar {
font-size: 14px;
display: flex;
gap: 20px;
}
.reaction {
display: flex;
align-items: center;
gap: 6px;
}
button {
width: var(--size);
height: var(--size);
padding: 0;
cursor: pointer;
transition: 0.3s;
border: none;
border-radius: calc(var(--size) / 2);
background-color: transparent;
--size: 40px;
}
button:hover {
color: rgb(242, 43, 131);
background-color: rgba(242, 43, 131, 0.3);
}
Also see: Tab Triggers