aboutsummaryrefslogtreecommitdiff
path: root/build/better-box-shadows
diff options
context:
space:
mode:
authorbt <bt@btxx.org>2024-06-08 13:22:19 -0400
committerbt <bt@btxx.org>2024-06-08 13:22:19 -0400
commitdcfb172704f3afb68a30425029ec834be2883274 (patch)
tree02ac480745db802d7af03f3213a0c568322170e3 /build/better-box-shadows
parente146f8a64c793c337999ce316b16ebe5fe6f2dab (diff)
More content porting, on-going markdown changes for lowdown support
Diffstat (limited to 'build/better-box-shadows')
-rw-r--r--build/better-box-shadows/index.html109
1 files changed, 49 insertions, 60 deletions
diff --git a/build/better-box-shadows/index.html b/build/better-box-shadows/index.html
index cfca3d3..c1fc50e 100644
--- a/build/better-box-shadows/index.html
+++ b/build/better-box-shadows/index.html
@@ -1,66 +1,43 @@
<!doctype html>
-<html lang="en" id="top">
+<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="data:,">
<title>Better Box Shadows</title>
- <link href="https://bt.ht/atom.xml" type="application/atom+xml" rel="alternate" title="Atom feed for blog posts" />
- <style>*{box-sizing:border-box;}body{font-family:sans-serif;margin:0 auto;max-width:650px;padding:1rem;}img{max-width:100%;}pre{overflow:auto;}table{text-align:left;width:100%;}</style>
+ <link href="/atom.xml" type="application/atom+xml" rel="alternate" title="Atom feed for blog posts" />
+ <link href="/rss.xml" type="application/rss+xml" rel="alternate" title="RSS feed for blog posts" />
+<style>*{box-sizing:border-box;}body{font-family:sans-serif;line-height:1.33;margin:0 auto;max-width:650px;padding:1rem;}img{max-width:100%;}pre{border:1px solid;overflow:auto;padding:5px;}table{text-align:left;width:100%;}.footnotes{font-size:90%;}</style>
</head>
<nav>
- <a href="#menu">Menu &darr;</a>
+ <a href="#menu">Menu &darr;</a>
</nav>
<main>
-<h1>Better Box Shadows</h1>
+<h1 id="better-box-shadows">Better Box Shadows</h1>
+
<p>2019-01-08</p>
-<p><style>
- .message {
- position: relative;
- z-index: 1;
- }
- .box-container,
- .box-container-depth {
- background: white;
- box-shadow: 0 4px 8px rgba(0,0,0,0.3);
- border: 1px solid #eee;
- border-radius: 10px;
- margin: 2rem auto;
- padding: 10px;
- position: relative;
- height: 200px;
- width: 250px;
- }
- .box-container-depth { box-shadow: none; }
- .box-container-depth .box-container-depth-inner {
- bottom: 0;
- box-shadow: 0 4px 12px rgba(0,0,0,0.3);
- content:'';
- position: absolute;
- width: 94%;
- height: 94%;
- left: 3%;
- z-index: -1;
- }
- .box-container-depth-inner.blur {
- filter: blur(6px);
- }
-</style></p>
-<p>Box shadow on <abbr title="hypertext markup language">HTML</abbr> elements has been widely supported across most browsers for a while now, but I find the default options don't allow for much visual manipulation of the shadows in general.</p>
-<p>Let's take a look at a default configuration of <code>box-shadow</code>:</p>
+
+<p>Box shadow on HTML elements has been widely supported across most browsers for a while now, but I find the default options don&#8217;t allow for much visual manipulation of the shadows in general.</p>
+
+<p>Let&#8217;s take a look at a default configuration of <code>box-shadow</code>:</p>
+
<pre><code>.box-container {
box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}
</code></pre>
+
<p>In the example above the first property number is the origin of the <em>x-axis</em>, the second number is the origin of the <em>y-axis</em> and the third is the amount of <em>blur</em>.</p>
+
<p>We should also add some minimal styling to cleanup the <code>.box-container</code> a little bit for our example:</p>
-<pre><code>&lt;div class=&quot;box-container&quot;&gt;&lt;/div&gt;
-</code></pre>
-<pre><code>.box-container {
+
+<pre><code>&#60;div class="box-container"&#62;&#60;&#47;div&#62;
+
+
+.box-container {
box-shadow: 0 4px 8px rgba(0,0,0,0.3);
- /* Styles to make it less ugly */
+ &#47;* Styles to make it less ugly *&#47;
background: white;
border-radius: 10px;
border: 1px solid #eee;
@@ -70,20 +47,27 @@
width: 250px;
}
</code></pre>
+
<p>Which would render as this:</p>
-<p><div class="box-container"></div></p>
+
<p>Not bad - but we can do a lot better than this.</p>
-<h2>Please sir, I want some more (depth)</h2>
+
+<h2 id="please-sir-i-want-some-more-depth">Please sir, I want some more (depth)</h2>
+
<p>We just need to add a simple child <code>div</code> (or use a <code>pseudo</code> element if you prefer) inside our main element we want to apply the shadow to:</p>
-<pre><code>&lt;div class=&quot;box-container&quot;&gt;
- &lt;div class=&quot;box-container-inner&quot;&gt;&lt;/div&gt;
-&lt;/div&gt;
+
+<pre><code>&#60;div class="box-container"&#62;
+ &#60;div class="box-container-inner"&#62;&#60;&#47;div&#62;
+&#60;&#47;div&#62;
</code></pre>
-<p>Now we make our inner child element <code>absolute</code> and set it's <code>height</code> and <code>width</code> dynamically to be slightly smaller than it's parent (percentages work best for this). </p>
-<p>Remember to set this child element behind it's parent by adding <code>z-index: -1</code>.</p>
+
+<p>Now we make our inner child element <code>absolute</code> and set it&#8217;s <code>height</code> and <code>width</code> dynamically to be slightly smaller than it&#8217;s parent (percentages work best for this). </p>
+
+<p>Remember to set this child element behind it&#8217;s parent by adding <code>z-index: -1</code>.</p>
+
<pre><code>.box-container {
- /* No box-shadow needed on this element anymore */
- /* Styles to make it less ugly */
+ &#47;* No box-shadow needed on this element anymore *&#47;
+ &#47;* Styles to make it less ugly *&#47;
background: white;
border-radius: 10px;
border: 1px solid #eee;
@@ -93,11 +77,14 @@
width: 250px;
}
</code></pre>
-<h2>Inner Containers</h2>
+
+<h2 id="inner-containers">Inner Containers</h2>
+
<p>We also need to target the <code>box-container-inner</code> element set inside the current parent to reflect our custom shadow styling:</p>
+
<pre><code>.box-container-inner {
bottom: 0;
- /* The box-shadow is added here now */
+ &#47;* The box-shadow is added here now *&#47;
box-shadow: 0 4px 12px rgba(0,0,0,0.3);
height: 94%;
left: 3%;
@@ -106,13 +93,17 @@
z-index: -1;
}
</code></pre>
+
<p>Which will make the drop-shadow render with a little more realistic depth:</p>
-<p><div class="box-container-depth"><span class="box-container-depth-inner"></span></div></p>
-<h2>But wait - there's more!</h2>
+
+<h2 id="but-wait---theres-more">But wait - there&#8217;s more!</h2>
+
<p>We could stop now and have a decent drop-shadow that is certainly easier on the eyes - but we can make this even better with one extra property - <code>filter:blur();</code>. </p>
+
<p>So your final code would look like this:</p>
+
<pre><code>.box-container {
- /* Styles to make it less ugly */
+ &#47;* Styles to make it less ugly *&#47;
background: white;
border-radius: 10px;
border: 1px solid #eee;
@@ -133,10 +124,8 @@
z-index: -1;
}
</code></pre>
+
<p>Which renders out into a much smoother blend of a drop-shadow, creating a more realistic illusion of depth:</p>
-<p><div class="box-container-depth">
- <span class="box-container-depth-inner blur"></span>
-</div></p>
<footer role="contentinfo">
<h2>Menu Navigation</h2>
<ul id="menu">