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">
<section class="demo">
<h1>ΠΠ»Π΅ΠΌΠ΅Π½ΡΡ ΡΠΎΡΠΌΡ Π² Π³ΡΠΈΠ΄Π΅</h1>
<!-- Π΄Π²Π° ΠΈΠ·ΠΎΠ±ΡΠ°ΠΆΠ΅Π½ΠΈΡ -->
<!-- <div class="grid">
<img src="http://fillmurray.com/400/300">
<img src="http://fillmurray.com/400/300">
</div>
-->
<!-- Π΄Π²Π° ΠΏΠΎΠ»Ρ number -->
<div class="grid">
<input type="number">
<input type="number">
</div>
<!-- Π΄Π²Π° ΡΠ»Π΅ΠΌΠ΅Π½ΡΠ° progress -->
<div class="grid">
<progress></progress>
<progress></progress>
</div>
<!-- Π΄Π²Π° ΠΏΡΡΡΡΡ
ΠΏΠΎΠ»Ρ -->
<div class="grid">
<input>
<input>
</div>
<!-- Π΄Π²Π° ΠΊΠΎΡΠΎΡΠΊΠΈΡ
Π±ΠΎΠΊΡΠ° ΡΠ΅Π»Π΅ΠΊΡΠ° -->
<div class="grid">
<select><option>Foo</option></select>
<select><option>Bar</option></select>
</div>
<!-- Π΄Π²Π° Π΄Π»ΠΈΠ½Π½ΡΡ
Π±ΠΎΠΊΡΠ° ΡΠ΅Π»Π΅ΠΊΡΠ° -->
<div class="grid">
<select><option>ΡΡΠΎ ΡΠ΅Π°Π»ΡΠ½Π°Ρ ΡΠΈΡΠΈΠ½Π° Π±ΠΎΠΊΡΠ° ΡΠ΅Π»Π΅ΠΊΡΠ°</option></select>
<select><option>ΡΡΠΎ ΡΠ΅Π°Π»ΡΠ½Π°Ρ ΡΠΈΡΠΈΠ½Π° Π±ΠΎΠΊΡΠ° ΡΠ΅Π»Π΅ΠΊΡΠ°</option></select>
</div>
<!-- ΠΏΠΎΠ»Ρ Π²Π½ΡΡΡΠΈ div -->
<div class="grid">
<div><input></div>
<div><input></div>
</div>
<!-- ΡΠ΅Π»Π΅ΠΊΡΡ Π²Π½ΡΡΡΠΈ div -->
<div class="grid">
<div><select><option>ΡΡΠΎ ΡΠ΅Π°Π»ΡΠ½Π°Ρ ΡΠΈΡΠΈΠ½Π° Π±ΠΎΠΊΡΠ° ΡΠ΅Π»Π΅ΠΊΡΠ°</option></select></div>
<div><select><option>ΡΡΠΎ ΡΠ΅Π°Π»ΡΠ½Π°Ρ ΡΠΈΡΠΈΠ½Π° Π±ΠΎΠΊΡΠ° ΡΠ΅Π»Π΅ΠΊΡΠ°</option></select></div>
</div>
<!-- ΠΏΠΎΠ»Ρ Ρ ΡΠΈΠΏΠΎΠΌ file -->
<div class="grid">
<input type="file">
<input type="file">
</div>
<!-- ΠΊΠ½ΠΎΠΏΠΊΠΈ submit -->
<div class="grid">
<input type="submit">
<input type="submit">
</div>
<!-- ΠΏΠΎΠ»Ρ reset -->
<div class="grid">
<input type="reset">
<input type="reset">
</div>
<!-- ΠΊΠΎΡΠΎΡΠΊΠΈΠ΅ ΠΊΠ½ΠΎΠΏΠΊΠΈ -->
<div class="grid">
<button>ΠΡΠΈΠ²Π΅ΡΠΈΠΊ</button>
<button>ΠΡΠΈΠ²Π΅ΡΠΈΠΊ</button>
</div>
<!-- Π΄Π»ΠΈΠ½Π½ΡΠ΅ ΠΊΠ½ΠΎΠΏΠΊΠΈ -->
<div class="grid">
<button>ΠΡΠΈΠ²Π΅ΡΠΈΠΊ, ΠΏΡΠΈΡΡΠ΅Π»Ρ, ΠΊΠ°ΠΊ Π΄Π΅Π»Π°?</button>
<button>ΠΡΠΈΠ²Π΅ΡΠΈΠΊ, ΠΏΡΠΈΡΡΠ΅Π»Ρ, ΠΊΠ°ΠΊ Π΄Π΅Π»Π°?</button>
</div>
<!-- ΠΊΠ½ΠΎΠΏΠΊΠΈ Π²Π½ΡΡΡΠΈ div-ΠΎΠ² -->
<div class="grid">
<div><button>ΠΡΠΈΠ²Π΅ΡΠΈΠΊ, ΠΏΡΠΈΡΡΠ΅Π»Ρ, ΠΊΠ°ΠΊ Π΄Π΅Π»Π°?</button></div>
<div><button>ΠΡΠΈΠ²Π΅ΡΠΈΠΊ, ΠΏΡΠΈΡΡΠ΅Π»Ρ, ΠΊΠ°ΠΊ Π΄Π΅Π»Π°?</button></div>
</div>
</section>
<header>
<p>Π‘Π΅Π³ΠΎΠ΄Π½Ρ Ρ ΡΠ·Π½Π°Π», ΡΡΠΎ ΠΈΠ·-Π·Π° ΡΠ»Π΅ΠΌΠ΅Π½ΡΠΎΠ² <code>input</code> Π² Π³ΡΠΈΠ΄Π°Ρ
ΠΎΠ½ΠΈ ΠΏΠ΅ΡΠ΅ΡΡΠ°Π½ΡΡ Π±ΡΡΡ Π°Π΄Π°ΠΏΡΠΈΠ²Π½ΡΠΌΠΈ. ΠΡΠΎ ΠΌΠΎΠΆΠ½ΠΎ ΠΏΠΎΡΠΈΠΊΡΠΈΡΡ Π² Chrome, ΡΠ΄Π°Π»ΠΈΠ² min-width (ΠΊΠΎΡΠΎΡΡΠΉ Π²ΠΈΠ΄ΠΈΠΌΠΎ Π½Π΅ ΡΠΊΠ°Π·Π°Π½ Π² ΠΎΡΠ»Π°Π΄ΡΠΈΠΊΠ΅). Π’Π΅ΠΊΡΡ/ΠΈΠ·ΠΎΠ±ΡΠ°ΠΆΠ΅Π½ΠΈΡ ΡΠΆΠΈΠΌΠ°ΡΡΡΡ ΠΊΠ°ΠΊ ΠΈ ΠΎΠΆΠΈΠ΄Π°Π»ΠΎΡΡ. ΠΠ½ΡΡΡΡΠΊΡΠΈΡ:
</p>
<ul>
<li>ΠΠΎΠΈΠ·ΠΌΠ΅Π½ΡΠΉΡΠ΅ ΡΠ°Π·ΠΌΠ΅Ρ ΠΎΠΊΠ½Π° Π΄ΠΎ ΠΏΠΎΡΠ²Π»Π΅Π½ΠΈΡ Π³ΠΎΡΠΈΠ·ΠΎΠ½ΡΠ°Π»ΡΠ½ΠΎΠ³ΠΎ ΡΠΊΡΠΎΠ»Π»Π±Π°ΡΠ°.</li>
<li><strong>ΠΠΆΠΈΠ΄Π°Π½ΠΈΠ΅:</strong> Π½Π΅Ρ Π³ΠΎΡΠΈΠ·ΠΎΠ½ΡΠ°Π»ΡΠ½ΠΎΠ³ΠΎ ΡΠΊΡΠΎΠ»Π»Π°, ΠΊΠΎΠ½ΡΠ΅Π½Ρ ΠΏΡΠΎΠ΄ΠΎΠ»ΠΆΠ°Π΅Ρ ΡΠΆΠΈΠΌΠ°ΡΡΡΡ.</li>
<li><strong>Π Π΅Π°Π»ΡΠ½ΠΎΡΡΡ:</strong> ΠΏΠΎΠ»Ρ ΠΏΠ΅ΡΠ΅ΡΡΠ°ΡΡ ΡΠΆΠΈΠΌΠ°ΡΡΡΡ ΠΈ ΠΏΠΎΡΠ²Π»ΡΠ΅ΡΡΡ Π³ΠΎΡΠΈΠ·ΠΎΠ½ΡΠ°Π»ΡΠ½Π°Ρ ΠΏΠΎΠ»ΠΎΡΠ° ΠΏΡΠΎΠΊΡΡΡΠΊΠΈ
</ul>
<p>Π¨Π°Π³ 1: Π£Π΄Π°Π»ΠΈΡΡ `min-width: auto` ΠΈΠ· ΡΠ»Π΅ΠΌΠ΅Π½ΡΠΎΠ² Π³ΡΠΈΠ΄Π°. </p>
<button id="removeMinWidth">ΠΡΠΈΠΌΠ΅Π½ΡΠ΅ΠΌ ΠΊ Π½ΠΈΠΌ min-width: 0.</button>
<p>Π¨Π°Π³ 2: ΠΠΎΠ±Π°Π²Π»ΡΠ΅ΠΌ max-width.</p>
<button id="addMaxWidth">
ΠΠΎΠ±Π°Π²Π»ΡΠ΅ΠΌ max-width ΠΊ ΠΊΠΎΠ½ΡΡΠΎΠ»Π°ΠΌ ΡΠΎΡΠΌΡ.
</button>
<p>Π¨Π°Π³ 3: ΠΠ°ΡΡΠ°Π²Π»ΡΠ΅ΠΌ ΠΏΠΎΠ»Ρ Ρ ΡΠΈΠΏΠΎΠΌ file ΠΈ submit ΠΏΠ΅ΡΠ΅Π½ΠΎΡΠΈΡΡ ΡΠ΅ΠΊΡΡ</p>
<button id="wrapText">ΠΠ°ΡΡΠ°Π²Π»ΡΠ΅ΠΌ ΠΏΠΎΠ»Ρ ΠΏΠ΅ΡΠ΅Π½ΠΎΡΠΈΡΡ ΡΠ΅ΠΊΡΡ</button>
<p>Π¨Π°Π³ 4: ΠΠ°Π΄Π°ΡΠΌ range, number, ΠΈ progress ΠΏΠΎΠ»Π½ΡΡ ΡΠΈΡΠΈΠ½Ρ: </p>
<button id="width100">ΠΠ°Π΄Π°ΡΠΌ ΡΡΠΈΠΌ ΡΠΈΠΏΠ°ΠΌ ΠΊΠΎΠ½ΡΡΠΎΠ»ΠΎΠ² max-width
</button>
<p>ΠΡΠ»ΠΈ ΡΠ΄Π΅Π»Π°ΡΡ Π΅ΡΡ ΠΎΠ΄ΠΈΠ½ ΡΠ°Π³ ΠΈ Π·Π°Π΄Π°ΡΡ ΡΠΈΡΠΈΠ½Π°ΠΌ input/select `width: 100%`, ΡΠΎ ΡΠ°Π³ΠΈ 1 ΠΈ 2 Π½Π΅ ΠΏΠΎΠ½Π°Π΄ΠΎΠ±ΡΡΡΡ. ΠΠΎ ΡΠ°Π³ 1 ΠΈΡΠΏΡΠ°Π²Π»ΡΠ΅Ρ Π΅ΡΡ ΠΎΠ΄Π½Ρ ΠΏΡΠΎΠ±Π»Π΅ΠΌΡ (`overflow-x` Π½Π° ΡΠ»Π΅ΠΌΠ΅Π½ΡΠ°Ρ
), Π° ΡΠ°Π³ 2 ΠΊΠ°ΠΆΠ΅ΡΡΡ ΡΠ°Π·ΡΠΌΠ½ΡΠΌ Π·Π½Π°ΡΠ΅Π½ΠΈΠ΅ΠΌ ΠΏΠΎ ΡΠΌΠΎΠ»ΡΠ°Π½ΠΈΡ.
</p>
</header>
</div>
// Π Π΅ΡΠ΅Ρ
* {
box-sizing: border-box;
}
header {
background: #fee;
padding: 1em;
margin-bottom: 2em;
}
.container {
padding: 2em;
max-width: 1234px;
margin: 0 auto;
}
button.active {
background: green;
color: white;
}
.grid {
display: grid;
grid-template-columns: 1fr 1fr;
grid-gap: 2em;
margin-bottom: 1em;
}
body.removeMinWidth {
// &:before {
// content: '.grid > * { min-width: 0; }';
// position: fixed;
// background: red;
// top: 0;
// }
.grid > * {
min-width: 0;
}
}
body.addMaxWidth {
img,
video,
audio,
canvas,
input,
select,
button,
progress {
max-width: 100%;
}
}
body.wrapText {
input {
white-space: pre-wrap;
}
}
body.width100 {
input[type="range"],
progress {
width: 100%;
}
@supports (--moz-appearance: none) {
input[type="number"] { width: 100%; }
}
// ΠΠ΅ΡΠ΅ΠΎΠΏΡΠ΅Π΄Π΅Π»Π΅Π½ΠΈΠ΅ βΠ²Π½ΡΡΡΠ΅Π½Π½ΠΈΡ
ΡΠ°Π·ΠΌΠ΅ΡΠΎΠ²β Π·Π°ΠΌΠ΅ΡΠ°Π΅ΠΌΡΡ
ΡΠ»Π΅ΠΌΠ΅Π½ΡΠΎΠ².
}
document.querySelector('button#removeMinWidth').addEventListener('click', function( event ){
event.preventDefault();
document.body.classList.toggle('removeMinWidth');
this.classList.toggle('active');
});
document.querySelector('button#addMaxWidth').addEventListener('click', function( event ){
event.preventDefault();
document.body.classList.toggle('addMaxWidth');
this.classList.toggle('active');
})
document.querySelector('button#wrapText').addEventListener('click', function( event ){
event.preventDefault();
document.body.classList.toggle('wrapText');
this.classList.toggle('active');
})
document.querySelector('button#width100').addEventListener('click', function( event ){
event.preventDefault();
document.body.classList.toggle('width100');
this.classList.toggle('active');
})
Also see: Tab Triggers