diff options
Diffstat (limited to 'build/posts/keynote-slides-css/index.html')
-rw-r--r-- | build/posts/keynote-slides-css/index.html | 120 |
1 files changed, 0 insertions, 120 deletions
diff --git a/build/posts/keynote-slides-css/index.html b/build/posts/keynote-slides-css/index.html deleted file mode 100644 index 528376c..0000000 --- a/build/posts/keynote-slides-css/index.html +++ /dev/null @@ -1,120 +0,0 @@ -<!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>Keynote Slides with Pure CSS</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 ↓</a> -</nav> - -<main> -<h1 id="keynote-slides-with-pure-css">Keynote Slides with Pure CSS</h1> -<p>2020-06-22</p> -<p>There are a great deal of options available on the web and built into most operating systems when you need to create presentation / keynote slides. You could use native software like LibremOffice Impress, Powerpoint, Apple’s Keynote, etc. You could also decide to use preexisting web-based apps like Google Slides or an open source project such as RevealJS. All of these are good options.</p> -<p>But thinking more about how overly complex these apps are implemented, it got me wondering if I could quickly code up a presentation slide framework with pure CSS and barely any code.</p> -<p>This is what I came up with:</p> -<h2 id="the-demo">The Demo</h2> -<p><a href="https://codepen.io/bradleytaunt/pen/jOWBJZb">Live CodePen Example</a></p> -<p>Yes, I know this is <em>ugly</em>, but this was created as a barebones skeleton for others to build upon. The demo uses a simple set of <code>radio</code> inputs that correspond to their own individual <code>slide</code> element. The framework looks at the currently <code>checked</code> input, then changes the <code>opacity</code> and <code>z-index</code> of its corresponding slide item. Pretty straightforward stuff!</p> -<p>Let’s break down each piece:</p> -<h2 id="the-html">The HTML</h2> -<pre><code><div class="slider"> - <input type="radio" name="pagination" value="1" checked> - <input type="radio" name="pagination" value="2"> - <input type="radio" name="pagination" value="3"> - <input type="radio" name="pagination" value="4"> - <input type="radio" name="pagination" value="5"> - - <div class="slide"> - <h2>Slide 1</h2> - </div> - <div class="slide"> - <h2>Slide 2</h2> - </div> - <div class="slide"> - <h2>Slide 3</h2> - </div> - <div class="slide"> - <h2>Slide 4</h2> - </div> - <div class="slide"> - <h2>Slide 5</h2> - </div> -</div> -</code></pre> -<p>There isn’t a whole lot going on here. We are just including a set of <code>radio</code> inputs (based on how many slides are desired) along with their corresponding <code>slide</code> class elements. You might notice we don’t do anything to specifically target each individual slide item - you’ll see why we don’t need to in the CSS section!</p> -<h2 id="the-css-scss">The CSS (SCSS)</h2> -<pre><code>/* Basic default styles */ -.slider { - height: 100%; - left: 0; - position: fixed; - top: 0; - width: 100%; - - .slide { - height: 100%; - opacity: 0; - position: absolute; - width: 100%; - z-index: -2; - } -} - -input[type="radio"] { cursor: pointer; } - -/* Target slide item based on currently checked radio */ -input[type="radio"]:nth-of-type(1):checked ~ .slide:nth-of-type(1), -input[type="radio"]:nth-of-type(2):checked ~ .slide:nth-of-type(2), -input[type="radio"]:nth-of-type(3):checked ~ .slide:nth-of-type(3), -input[type="radio"]:nth-of-type(4):checked ~ .slide:nth-of-type(4), -input[type="radio"]:nth-of-type(5):checked ~ .slide:nth-of-type(5) { - opacity: 1; - z-index: 1; -} - -/* Individual slide styling */ -.slide:nth-of-type(1) { background: dodgerblue; } -.slide:nth-of-type(2) { background: crimson; } -.slide:nth-of-type(3) { background: rebeccapurple; } -.slide:nth-of-type(4) { background: goldenrod; } -.slide:nth-of-type(5) { background: pink; } -</code></pre> -<p>Again, not much to see here. We use CSS to look down through the DOM for each <code>radio</code> elements slide “partner”. We do this by targeting the <code>nth-of-type</code> on both elements. Simple stuff.</p> -<p>Some drawbacks to this approach:</p> -<ul> -<li>You need to manually target each new slide you add (color, styling, content, etc.)</li> -<li>Lack of animations might require extra work to implement (maybe 3rd party libraries- ke AOS?)</li> -<li>Probably won’t be best for extremely long/complex presentation slides</li> -</ul> -<p>That’s it! Hope you enjoy playing around with it.</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://barf.btxx.org">barf</a>. <br> - Feeds: <a href="/atom.xml">Atom</a> & <a href="/rss.xml">RSS</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 |