aboutsummaryrefslogtreecommitdiff
path: root/build/keynote-slides-css/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'build/keynote-slides-css/index.html')
-rw-r--r--build/keynote-slides-css/index.html117
1 files changed, 117 insertions, 0 deletions
diff --git a/build/keynote-slides-css/index.html b/build/keynote-slides-css/index.html
new file mode 100644
index 0000000..45175c6
--- /dev/null
+++ b/build/keynote-slides-css/index.html
@@ -0,0 +1,117 @@
+<!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>Keynote Slides with Pure CSS</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 &darr;</a>
+</nav>
+
+<main>
+<h1>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>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>The HTML</h2>
+<pre><code>&lt;div class=&quot;slider&quot;&gt;
+ &lt;input type=&quot;radio&quot; name=&quot;pagination&quot; value=&quot;1&quot; checked&gt;
+ &lt;input type=&quot;radio&quot; name=&quot;pagination&quot; value=&quot;2&quot;&gt;
+ &lt;input type=&quot;radio&quot; name=&quot;pagination&quot; value=&quot;3&quot;&gt;
+ &lt;input type=&quot;radio&quot; name=&quot;pagination&quot; value=&quot;4&quot;&gt;
+ &lt;input type=&quot;radio&quot; name=&quot;pagination&quot; value=&quot;5&quot;&gt;
+
+ &lt;div class=&quot;slide&quot;&gt;
+ &lt;h2&gt;Slide 1&lt;/h2&gt;
+ &lt;/div&gt;
+ &lt;div class=&quot;slide&quot;&gt;
+ &lt;h2&gt;Slide 2&lt;/h2&gt;
+ &lt;/div&gt;
+ &lt;div class=&quot;slide&quot;&gt;
+ &lt;h2&gt;Slide 3&lt;/h2&gt;
+ &lt;/div&gt;
+ &lt;div class=&quot;slide&quot;&gt;
+ &lt;h2&gt;Slide 4&lt;/h2&gt;
+ &lt;/div&gt;
+ &lt;div class=&quot;slide&quot;&gt;
+ &lt;h2&gt;Slide 5&lt;/h2&gt;
+ &lt;/div&gt;
+&lt;/div&gt;
+</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>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=&quot;radio&quot;] { cursor: pointer; }
+
+/* Target slide item based on currently checked radio */
+input[type=&quot;radio&quot;]:nth-of-type(1):checked ~ .slide:nth-of-type(1),
+input[type=&quot;radio&quot;]:nth-of-type(2):checked ~ .slide:nth-of-type(2),
+input[type=&quot;radio&quot;]:nth-of-type(3):checked ~ .slide:nth-of-type(3),
+input[type=&quot;radio&quot;]:nth-of-type(4):checked ~ .slide:nth-of-type(4),
+input[type=&quot;radio&quot;]: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">&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