diff options
author | Bradley Taunt <bt@btxx.org> | 2024-06-06 08:05:12 -0400 |
---|---|---|
committer | Bradley Taunt <bt@btxx.org> | 2024-06-06 08:05:12 -0400 |
commit | 6b742c459266b18e2b375b35205ce8a6c02f0452 (patch) | |
tree | b16fbb9a045e33dd6c97eb5ab72e6ff4d9237ea3 /build/notice/index.html |
Initial commit
Diffstat (limited to 'build/notice/index.html')
-rw-r--r-- | build/notice/index.html | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/build/notice/index.html b/build/notice/index.html new file mode 100644 index 0000000..573a2d2 --- /dev/null +++ b/build/notice/index.html @@ -0,0 +1,102 @@ +<!doctype html> +<html lang="en" id="top"> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <link rel="icon" href="data:,"> + <title>RE: Creating a Simple HTML/CSS Notice Box</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> +</head> + +<nav> + <a href="#menu">Menu ↓</a> +</nav> + +<main> +<h1>RE: Creating a Simple HTML/CSS Notice Box</h1> +<p>2022-09-22</p> +<p>I recently read Kev Quirk's post, <a href="https://kevquirk.com/how-to-create-a-simple-html-css-notice-box/">How to Create a Simple HTML/CSS Notice Box</a> and loved the simplicity of it. I'm a sucker for using pseudo elements in creative ways but still managing to make them useful. Of course, this got me thinking as to whether or not the same style of box could be achieved <em>without</em> the use of static, pseudo elements...</p> +<h2>Bad Semantics</h2> +<p>I need to make it clear right away: <strong>these implementations are not semantic</strong>. They are valid HTML, but I am technically using these tags incorrectly. <em>You have been warned!</em></p> +<h2>Setting Fieldsets</h2> +<p>The first approach is to wrap everything inside HTML <code>fieldset</code> tags:</p> +<pre><code><fieldset> + <legend>Notice</legend> + <p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Totam nihil velit vitae sed beatae earum assumenda deleniti, inventore repellendus, sequi distinctio delectus porro explicabo quidem hic quo quasi voluptas temporibus.</p> +</fieldset> +</code></pre> +<p>Then you can include minor styling to closely match the design of Kev's notice box:</p> +<pre><code>fieldset { + border: 3px solid; + font-family: sans-serif; + padding: 30px 10px 10px; + position: relative; +} +fieldset legend { + background: #AACCFF; + border-bottom: 3px solid; + border-right: 3px solid; + left: 0; + margin: 0; + padding: 5px 10px; + position: absolute; + top: 0; + text-transform: uppercase; +} +</code></pre> +<h2>The Devil is in the Details</h2> +<p>The other option is utilizing the HTML <code>details</code> tag:</p> +<pre><code><details open> + <summary>Notice</summary> + <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Assumenda sequi esse reprehenderit facilis aperiam labore optio minus doloremque nesciunt! Voluptatem esse tempore asperiores recusandae rerum facere, reiciendis officia repudiandae similique?</p> +</details> +</code></pre> +<p>You'll obviously want to include the <code>open</code> attribute to avoid users needing to toggle the content manually (unless that is your desired UX). Then add similar styling options to match the <code>fieldset</code> example:</p> +<pre><code>details { + border: 3px solid; + font-family: sans-serif; + padding: 0 10px 10px; +} +details summary { + background: #AACCFF; + border-bottom: 3px solid; + border-right: 3px solid; + display: inline-block; + margin-left: -10px; + padding: 5px 10px; + text-transform: uppercase; +} +</code></pre> +<p>Important to note: you can hide the default "arrow toggle" on <code>summary</code> elements by including the following:</p> +<pre><code>details > summary { +list-style: none; +} +details > summary::-webkit-details-marker { +display: none; +} +</code></pre> +<h2>Seeing is Believing</h2> +<p>I've put together two versions of each implementation (one custom designed and one using default browser styling). You can check them out in the CodePen below:</p> +<p><a href="https://codepen.io/bradleytaunt/pen/jOxLdQP">Live CodePen Example</a></p> +<footer role="contentinfo"> + <h2>Menu Navigation</h2> + <ul id="menu"> + <li><a href="/">Home</a></li> + <li><a href="/projects">Projects</a></li> + <li><a href="/uses">Uses</a></li> + <li><a href="/wiki">Wiki</a></li> + <li><a href="/resume">Resume</a></li> + <li><a href="/colophon">Colophon</a></li> + <li><a href="/now">Now</a></li> + <li><a href="/donate">Donate</a></li> + <li><a href="/atom.xml">RSS</a></li> + <li><a href="#top">↑ Top of the page</a></li> + </ul> + <small> + Built with <a href="https://git.sr.ht/~bt/barf">barf</a>. <br> + Maintained with ♥ for the web. <br> + Proud supporter of <a href="https://usefathom.com/ref/DKHJVX">Fathom</a> & <a href="https://nextdns.io/?from=74d3p3h8">NextDNS</a>. <br> + The content for this site is <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>.<br> The <a href="https://git.sr.ht/~bt/bt.ht">code for this site</a> is <a href="https://git.sr.ht/~bt/bt.ht/tree/master/item/LICENSE">MIT</a>. + </small> +</footer>
\ No newline at end of file |