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.
<body class="dark-mode flex align-center justify-center">
<div class="grid columns-2">
<header class="span-all flex align-center space-between">
<h1><code>box-shadow</code> Examples</h1>
<a class="wl-button small icon" href="https://xhynk.com/" target="_blank">Made with 💖 by @Xhynk <i data-feather="chevron-right"></i></a>
</header>
<div class="wl-modal visible warning stark">
<header class="flex space-between">
<h4 class="flex align-center">
<div class="icon"><i data-feather="frown"></i></div>
<span>Stark Shadow</span>
</h4>
</header>
<div class="content">This block has a very stark shadow. It's very bold and abrupt. It certainly has its place, but it doesn't look great on elements like this. Let's keep going.</div>
<pre>box-shadow: 0 12px 20px #000;</pre>
</div>
<div class="wl-modal visible warning color">
<header class="flex space-between">
<h4 class="flex align-center">
<div class="icon"><i data-feather="meh"></i></div>
<span>Colored Shadow</span>
</h4>
</header>
<div class="content">This block has a colored shadow that is a hex color based on the element itself and the background. This looks alright, but it will look bad if we have it on a different colored background</div>
<pre>box-shadow: 0 12px 20px #1b1e20;</pre>
</div>
<div class="wl-modal visible alpha">
<header class="flex space-between">
<h4 class="flex align-center">
<div class="icon"><i data-feather="smile"></i></div>
<span>Alpha Shadow</span>
</h4>
</header>
<div class="content">This block uses RGBA instead of a Hex color value to lighten the shadow. This works well to soften it, regardless of the background color - so it looks decent just about anywhere, and doesn't need modification.</div>
<pre>box-shadow: 0 12px 20px rgba(0,0,0,.35);</pre>
</div>
<div class="wl-modal visible success subtle">
<header class="flex space-between">
<h4 class="flex align-center">
<div class="icon"><i data-feather="award"></i></div>
<span>Subtle Shadow</span>
</h4>
</header>
<div class="content">This block makes use of <code>box-shadow</code>'s optional 4th argument, the "spread radius" or "choke". A positive value increases the spread, making it bolder. A negative value lowers the spread, making it more subtle! (keep in mind this will affect the border-radius of the shadow in relation to the element!)</div>
<pre>box-shadow: 0 12px 24px -20px #000;</pre>
</div>
<div class="span-all text-center">
<a href="https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow" target="_blank" class="wl-button secondary icon">Read More on MDN <i data-feather="external-link"></i></a>
</div>
<div class="wl-modal visible inset">
<header class="flex space-between">
<h4 class="flex align-center">
<div class="icon"><i data-feather="plus-circle"></i></div>
<span>Inset Shadow</span>
</h4>
</header>
<div class="content">This block uses the <code>inset</code> value to invert the shadow and apply it <em>inside</em> the element instead of outside. The same subtlety principles apply here.</div>
<pre>box-shadow: inset 6px 6px 16px -12px #000;</pre>
</div>
<div class="wl-modal visible multi">
<header class="flex space-between">
<h4 class="flex align-center">
<div class="icon"><i data-feather="plus-circle"></i></div>
<span>Multi Shadow</span>
</h4>
</header>
<div class="content">You can chain together multiple box-shadows by comma separating them. This works with standard <em>and</em> inset shadows. Just… don't go <strong>too</strong> crazy…</div>
<pre>box-shadow: -16px -16px 0 rgba(0,138,255,.2),
inset 4px 4px 8px rgba(0,0,0,.5),
0 0 0 3px #0095ee,
16px 16px 0 rgba(255,255,255,.2);</pre>
</div>
<div class="nm-block span-all no-select">
<div class="re-center">
<div class="wl-modal visible neumorphic">
<header class="flex space-between">
<h4 class="flex align-center">
<div class="icon"><i data-feather="power"></i></div>
<span>Neumorphism</span>
</h4>
</header>
<div class="content">With a little finagling, two box shadows (and sometimes a linear-gradient on the element), we can achieve a nice <a href="https://uxdesign.cc/neumorphism-in-user-interfaces-b47cef3bf3a6" target="_blank">"Neumorphism"</a> effect. This one does work best when using colored shadows to more closely match the background element, as you can't quite achieve a natural look with just the opacity of pure black.
<p><strong>(Tip: Hover/click/tap on me!)</strong></p></div>
<pre>background: linear-gradient(145deg, #272c31, #202529);
box-shadow: 30px 30px 60px #1e2227,
-30px -30px 60px #2a3035;</pre>
</div>
</div>
</div>
<div class="wl-modal visible default span-all">
<header class="flex space-between">
<h4 class="flex align-center">
<div class="icon"><i data-feather="sun"></i></div>
<span>Bonus!</span>
</h4>
</header>
<div class="content">If you don't specify a color for your box shadow, it will default to the current <code>color</code> for that element (that's the <em>text color!</em>)</div>
<pre>box-shadow: 0 12px 24px;</pre>
</div>
</div>
<div class="easy-edit">
<a href="https://codepen.io/xhynk/pen/XWdOBwm/?editors=1100" target="_blank" class="wl-button primary small icon">Edit this Pen <i data-feather="edit"></i></a>
</body>
.stark { box-shadow: 0 12px 20px #000; }
.color { box-shadow: 0 12px 20px #161f2d; }
.alpha { box-shadow: 0 12px 20px rgba(0,0,0,.35); }
.subtle { box-shadow: 0 12px 24px -20px #000; }
.inset { box-shadow: inset 0 6px 14px -6px #000; }
.multi { box-shadow: -16px -16px 0 rgba(0,138,255,.2), inset 4px 4px 8px rgba(0,0,0,.5), 0 0 0 3px #0095ee, 16px 16px 0 rgba(255,255,255,.2); }
.default { box-shadow: 0 12px 24px; }
.neumorphic {
border-radius: 30px;
background-color: #24292e;
background: linear-gradient(145deg, #272c31, #202529) !important;
box-shadow: 30px 30px 60px #1e2227, -30px -30px 60px #2a3035;
&:hover {
cursor: pointer;
background: linear-gradient(145deg, #202529, #272c31) !important;
}
&:active {
background: #24292e !important;
box-shadow: inset 20px 20px 40px #1c2024, inset -20px -20px 40px #2c3238;
}
}
/**
* No need to look down here, this is just modifying the layout and such. Don't look at it, it's disgusting 🤮
*/
.no-select{-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select: none;user-select: none;-webkit-tap-highlight-color:transparent;}.easy-edit{position:fixed;bottom:10px;right:10px;z-index:101;}.nm-block{padding:100px;text-align:center;position:relative;&:after{content:"";position:absolute;background:#24292e;left:-100vw;right:-100vw;height:180%;top:0}.re-center{margin:0 auto;max-width:calc(100vw - 80px)}}.default{margin-top:3em!important}a:not(.wl-button){text-decoration:none;font-weight:600;color:#0095ee;&:hover{color:#22b7ff!important}}::-webkit-scrollbar-track{-webkit-box-shadow:none;background-color:transparent}::-webkit-scrollbar{width:16px;background-color:transparent}::-webkit-scrollbar-thumb{background-color:#0095ee;-webkit-border-radius:8px;border-radius:8px;border:6px solid #262b31}body{background-image:linear-gradient(100deg,#24292e 70%,#20252a 70.1%,#20252a calc(70.1% + 30px),#336284 calc(70.1% + 31px))!important;background-repeat:no-repeat!important;background-size:cover!important;background-attachment:fixed!important}h1{margin:0}.wl-modal{position:relative;max-height:none;max-width:none;min-width:0;width:100%;overflow:visible;z-index:10;text-align:left}.grid{grid-gap:3em;width:calc(100% - 80px);max-width:980px;margin:40px 0}*{box-sizing:border-box}svg,svg *{box-sizing:content-box}pre,code{background:rgba(0,0,0,.2);padding:0 .5em;overflow:auto}pre{max-width:100%}@media all and (max-width:860px){.grid[class*="columns"]{grid-template-columns:100%}.wl-modal{margin:0 auto;max-width:100%}}@media all and (max-width:480px){.grid{width:calc(100% - 36px)}}@media all and (max-width:768px){.nm-block{padding:80px 10%;}}
feather.replace();
var urlParams = new URLSearchParams(window.location.search);
editors = urlParams.get('editors');
if( editors != null ){
document.querySelector('.easy-edit').remove();
}
Also see: Tab Triggers