aboutsummaryrefslogtreecommitdiff
path: root/build/posts/poor-mans-full-bleed
diff options
context:
space:
mode:
authorBradley Taunt <bt@btxx.org>2024-06-10 09:41:25 -0400
committerBradley Taunt <bt@btxx.org>2024-06-10 09:41:25 -0400
commit07e4a2dafe248280b5610f8c7d09b0f30b530f54 (patch)
tree8a145d1d4d07e1278a837ff15dadccc322d27515 /build/posts/poor-mans-full-bleed
parent16d28628aca9b2d356de31c319f5e7bc0f5b2b02 (diff)
Initial modifications to rebuilt only changed files based on mod date, performance updates
Diffstat (limited to 'build/posts/poor-mans-full-bleed')
-rw-r--r--build/posts/poor-mans-full-bleed/index.html123
1 files changed, 123 insertions, 0 deletions
diff --git a/build/posts/poor-mans-full-bleed/index.html b/build/posts/poor-mans-full-bleed/index.html
new file mode 100644
index 0000000..8dd5e8e
--- /dev/null
+++ b/build/posts/poor-mans-full-bleed/index.html
@@ -0,0 +1,123 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <meta name="color-scheme" content="dark light">
+ <link rel="icon" href="data:,">
+ <title>Poor Man's CSS Full-Bleed Layout</title>
+ <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;}blockquote{background:rgba(0,0,0,0.1);border-left:4px solid;padding-left:5px;}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>
+</nav>
+
+<main>
+<h1 id="poor-mans-css-full-bleed-layout">Poor Man&#8217;s CSS Full-Bleed Layout</h1>
+<p>2020-10-07</p>
+<p>I recently came across the very well written and interesting article, <a href="https://joshwcomeau.com/css/full-bleed/">Full-Bleed Layout Using CSS Grid</a>, while browsing my daily designer feeds. I won&#8217;t go into the post&#8217;s specifics here (I recommend you read the article for yourself) but it details how to render full-bleed element effects utilizing the CSS <code>grid</code> property.</p>
+<p>While the approach in the article works perfectly fine, I thought to myself, &#8220;Is there not a simpler, more backwards compatible way to do this?&#8221;. Indeed there is.</p>
+<p><strong>Don&#8217;t care about the tutorial?</strong> <a href="#live-demo">Skip down to the live demo</a></p>
+<h2 id="make-the-web-backwards-compatible">Make the Web Backwards Compatible</h2>
+<p>I try my best when creating specific element designs or layouts to have everything render consistently across almost <em>all</em> browsers. This tends to include the obvious front-runners: Chrome, Firefox, Safari - but I also try my best not to ignore the oldies: IE11, Edge and older versions of Opera. I believe if most web designers even loosely followed this concept we wouldn&#8217;t be stringing together barely implemented CSS properties and hacking together polyfills for all the unsupported browsers. Just my two cents.</p>
+<p>What does this have to do with full-bleed exactly? Well, the CSS we will be using in this demo is fully compatible with pretty much <em>any browser</em> that can run the basic version of CSS rendering. If the browser you&#8217;re targeting supports <code>max-width</code> and <code>margins</code> - then have no fear, full-bleeds are here.</p>
+<h2 id="our-html-example">Our HTML Example</h2>
+<p>Let&#8217;s create a single-column blog layout for this example. We will include a heading, some paragraphs, an image, and a blockquote to keep it simple:</p>
+<pre><code>&#60;main&#62;
+ &#60;article&#62;
+ &#60;h1&#62;Main Heading&#60;&#47;h1&#62;
+ &#60;p&#62;Et non consequat eiusmod minim fugiat. Magna duis veniam ex reprehenderit occaecat sit. Nisi ut ex aliquip magna enim.&#60;&#47;p&#62;
+ &#60;p&#62;Lorem ipsum dolor sit amet consectetur adipisicing elit. Laborum repellat ab earum commodi, consequuntur totam adipisci doloremque asperiores quae at quia non temporibus ipsam voluptate voluptatem ipsa nostrum suscipit aliquid!&#60;&#47;p&#62;
+ &#60;img src=&#39;https:&#47;&#47;images.unsplash.com&#47;photo-1569083692634-f8db90c093ef?ixlib=rb-1.2.1&#38;q=85&#38;fm=jpg&#38;crop=entropy&#38;cs=srgb&#38;ixid=eyJhcHBfaWQiOjE0NTg5fQ&#39; alt="Some Image"&#62;
+ &#60;p&#62;Ex excepteur Lorem reprehenderit dolore in consequat voluptate commodo ipsum consequat ea et. Nisi tempor proident anim tempor. Laboris est sunt cillum deserunt culpa proident cillum laborum voluptate. Est exercitation Lorem reprehenderit eu ipsum nisi et.&#60;&#47;p&#62;
+ &#60;p&#62;Lorem ipsum dolor sit amet consectetur adipisicing elit. Ducimus dicta perspiciatis vel ex officiis, nisi optio nihil aspernatur exercitationem sed nobis architecto maxime eaque omnis eos, repellendus necessitatibus provident explicabo?&#60;&#47;p&#62;
+ &#60;p&#62;Lorem ipsum dolor sit amet consectetur adipisicing elit. Aliquid placeat ipsum totam, facere animi tenetur explicabo at veniam, culpa vitae debitis hic modi velit cum perferendis minima quos sit quisquam.&#60;&#47;p&#62;
+ &#60;blockquote&#62;
+ &#60;p&#62;To be, or not to be, that is the question:&#60;br&#62;Whether &#39;tis nobler in the mind to suffer&#60;br&#62;The slings and arrows of outrageous fortune,&#60;br&#62;Or to take Arms against a Sea of troubles,&#60;br&#62;And by opposing end them: to die, to sleep;&#60;&#47;p&#62;
+ &#60;cite&#62;- Some guy&#60;&#47;cite&#62;
+ &#60;&#47;blockquote&#62;
+ &#60;p&#62;Lorem ipsum dolor sit amet consectetur adipisicing elit. Ducimus dicta perspiciatis vel ex officiis, nisi optio nihil aspernatur exercitationem sed nobis architecto maxime eaque omnis eos, repellendus necessitatibus provident explicabo?&#60;&#47;p&#62;
+ &#60;p&#62;Lorem ipsum dolor sit amet consectetur adipisicing elit. Aliquid placeat ipsum totam, facere animi tenetur explicabo at veniam, culpa vitae debitis hic modi velit cum perferendis minima quos sit quisquam.&#60;&#47;p&#62;
+ &#60;&#47;article&#62;
+&#60;&#47;main&#62;
+</code></pre>
+<p>This works well as it is, but we will need to &#8220;section&#8221; off our different areas of content based on whether we want them <code>full-bleed</code> or not. We do this with - you guessed it - the <code>section</code> element. In this demo we want the image and blockquote to become <code>full-bleed</code> when rendered, so we&#8217;ll add the <code>full-bleed</code> class to those sections for now (more on that later):</p>
+<pre><code>&#60;main&#62;
+ &#60;article&#62;
+ &#60;section&#62;
+ &#60;h1&#62;Main Heading&#60;&#47;h1&#62;
+ &#60;p&#62;Et non consequat eiusmod minim fugiat. Magna duis veniam ex reprehenderit occaecat sit. Nisi ut ex aliquip magna enim.&#60;&#47;p&#62;
+ &#60;p&#62;Lorem ipsum dolor sit amet consectetur adipisicing elit. Laborum repellat ab earum commodi, consequuntur totam adipisci doloremque asperiores quae at quia non temporibus ipsam voluptate voluptatem ipsa nostrum suscipit aliquid!&#60;&#47;p&#62;
+ &#60;&#47;section&#62;
+ &#60;section class="full-bleed"&#62;
+ &#60;img src=&#39;https:&#47;&#47;images.unsplash.com&#47;photo-1569083692634-f8db90c093ef?ixlib=rb-1.2.1&#38;q=85&#38;fm=jpg&#38;crop=entropy&#38;cs=srgb&#38;ixid=eyJhcHBfaWQiOjE0NTg5fQ&#39; alt="Some Image"&#62;
+ &#60;&#47;section&#62;
+ &#60;section&#62;
+ &#60;p&#62;Ex excepteur Lorem reprehenderit dolore in consequat voluptate commodo ipsum consequat ea et. Nisi tempor proident anim tempor. Laboris est sunt cillum deserunt culpa proident cillum laborum voluptate. Est exercitation Lorem reprehenderit eu ipsum nisi et.&#60;&#47;p&#62;
+ &#60;p&#62;Lorem ipsum dolor sit amet consectetur adipisicing elit. Ducimus dicta perspiciatis vel ex officiis, nisi optio nihil aspernatur exercitationem sed nobis architecto maxime eaque omnis eos, repellendus necessitatibus provident explicabo?&#60;&#47;p&#62;
+ &#60;p&#62;Lorem ipsum dolor sit amet consectetur adipisicing elit. Aliquid placeat ipsum totam, facere animi tenetur explicabo at veniam, culpa vitae debitis hic modi velit cum perferendis minima quos sit quisquam.&#60;&#47;p&#62;
+ &#60;&#47;section&#62;
+ &#60;section class="full-bleed"&#62;
+ &#60;blockquote&#62;
+ &#60;p&#62;To be, or not to be, that is the question:&#60;br&#62;Whether &#39;tis nobler in the mind to suffer&#60;br&#62;The slings and arrows of outrageous fortune,&#60;br&#62;Or to take Arms against a Sea of troubles,&#60;br&#62;And by opposing end them: to die, to sleep;&#60;&#47;p&#62;
+ &#60;cite&#62;- Some guy&#60;&#47;cite&#62;
+ &#60;&#47;blockquote&#62;
+ &#60;&#47;section&#62;
+ &#60;section&#62;
+ &#60;p&#62;Lorem ipsum dolor sit amet consectetur adipisicing elit. Ducimus dicta perspiciatis vel ex officiis, nisi optio nihil aspernatur exercitationem sed nobis architecto maxime eaque omnis eos, repellendus necessitatibus provident explicabo?&#60;&#47;p&#62;
+ &#60;p&#62;Lorem ipsum dolor sit amet consectetur adipisicing elit. Aliquid placeat ipsum totam, facere animi tenetur explicabo at veniam, culpa vitae debitis hic modi velit cum perferendis minima quos sit quisquam.&#60;&#47;p&#62;
+ &#60;&#47;section&#62;
+ &#60;&#47;article&#62;
+&#60;&#47;main&#62;
+</code></pre>
+<p>That&#8217;s it for the HTML!</p>
+<h2 id="the-magic-css-not-really">The Magic CSS (Not Really)</h2>
+<p>Now take a deep breath and get ready for some hard CSS work:</p>
+<pre><code>article {
+ width: 100%;
+}
+
+article section {
+ margin: 0 auto;
+ max-width: 480px; &#47;* This can be whatever you want *&#47;
+ width: 100%;
+}
+article section.full-bleed {
+ max-width: 100%;
+}
+</code></pre>
+<p>That&#8217;s it. <em>Really</em>. Now any element (blockquotes, specific headers, navigations, footers, etc) that you want to layout as &#8220;full-bleed&#8221;, just wrap it in a <code>section</code> tag and sick the <code>full-bleed</code> class on it. Done and done.</p>
+<p>Obviously you&#8217;ll want to add more styling to clean-up and make your full-bleed layouts more beautiful. This demo was just more of a starting point.</p>
+<h3 id="maybe-not-quite-full-bleed">Maybe Not-Quite-Full-Bleed?</h3>
+<p>You could also further customize your options by including a class like <code>half-bleed</code>, which maybe only expands slightly outside the main section <code>max-width</code>:</p>
+<pre><code>article section.half-bleed {
+ max-width: 960px;
+}
+</code></pre>
+<h3 id="sidenote">Sidenote</h3>
+<p>For those concerned about accessibility: The <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/section">section element</a> is a flow content element, so it can contain almost all HTML elements.</p>
+<p><a href="https://codepen.io/bradleytaunt/pen/mdEdjzz">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">&uarr; 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> &amp; <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