<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>slideToggle on MXI</title><link>https://mxii.eu.org/tags/slidetoggle/</link><description>Recent content in slideToggle on MXI</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Thu, 07 Sep 2017 21:28:11 +0300</lastBuildDate><atom:link href="https://mxii.eu.org/tags/slidetoggle/index.xml" rel="self" type="application/rss+xml"/><item><title>JavaScript spoiler with a twist (collapsing up or down)</title><link>https://mxii.eu.org/2017/09/07/javascript-spoiler-with-a-twist-collapsing-up-or-down/</link><pubDate>Thu, 07 Sep 2017 21:28:11 +0300</pubDate><guid>https://mxii.eu.org/2017/09/07/javascript-spoiler-with-a-twist-collapsing-up-or-down/</guid><description>&lt;p>I thought that I will eventually need to use spoilers in this blog to hide long and optional blocks of text. And at the same time I&amp;rsquo;m often unhappy with collapsible block implementations across the Internet.&lt;/p>
&lt;p>So I decided to design my own spoiler with one useful feature: it can be collapsed not only from the top edge but also from the bottom edge &amp;mdash; you will not lose the line you were reading and you don&amp;rsquo;t have to scroll all the way to the beginning of the spoiler.&lt;/p>
&lt;p>Examples:&lt;/p>
&lt;div class="spoiler">
&lt;div class="spoiler-btn spoiler-btn-top">&lt;i class="fa-solid fa-chevron-down">&lt;/i> click to &lt;span class="show">show&lt;/span>&lt;span class="hide">hide&lt;/span>&lt;/div>
&lt;div class="spoiler-body">
&lt;p>This spoiler can be expanded up and down. And your mouse is left right over the button you just pressed whenever it is possible (on top and bottom of a page there may be not enough stuff to keep it so, obviously).&lt;/p>
&lt;p>&lt;img src="https://picsum.photos/410/410?random=1" alt="" />&lt;/p>
&lt;/div>
&lt;div class="spoiler-btn spoiler-btn-bottom">click to &lt;span class="show">show&lt;/span>&lt;span class="hide">hide&lt;/span> &lt;i class="fa-solid fa-chevron-up">&lt;/i>&lt;/div>
&lt;/div>
&lt;div class="spoiler simple">
&lt;div class="spoiler-btn spoiler-btn-top">&lt;i class="fa-solid fa-chevron-down">&lt;/i> click to &lt;span class="show">show&lt;/span>&lt;span class="hide">hide&lt;/span>&lt;/div>
&lt;div class="spoiler-body">
&lt;p>This spoiler can be expanded in one direction only. Collapsing behavior is still the same. The difference is just a few lines in CSS.&lt;/p>
&lt;p>&lt;img src="https://picsum.photos/410/410?random=2" alt="" />&lt;/p>
&lt;/div>
&lt;div class="spoiler-btn spoiler-btn-bottom">click to &lt;span class="show">show&lt;/span>&lt;span class="hide">hide&lt;/span> &lt;i class="fa-solid fa-chevron-up">&lt;/i>&lt;/div>
&lt;/div>
&lt;p>Keep reading to see how it is done.&lt;/p></description></item></channel></rss>