<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/rss-style.xsl" type="text/xsl"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	    xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	     xmlns:dc="http://purl.org/dc/elements/1.1/"
	   xmlns:atom="http://www.w3.org/2005/Atom"
	     xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	  xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>
<channel>
	<title>flexbox &#8211; Terence Eden’s Blog</title>
	<atom:link href="https://shkspr.mobi/blog/tag/flexbox/feed/" rel="self" type="application/rss+xml" />
	<link>https://shkspr.mobi/blog</link>
	<description>Regular nonsense about tech and its effects 🙃</description>
	<lastBuildDate>Mon, 28 Apr 2025 08:43:54 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://shkspr.mobi/blog/wp-content/uploads/2023/07/cropped-avatar-32x32.jpeg</url>
	<title>flexbox &#8211; Terence Eden’s Blog</title>
	<link>https://shkspr.mobi/blog</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title><![CDATA[Responsive Yearly Calendar with Flexbox]]></title>
		<link>https://shkspr.mobi/blog/2023/04/responsive-yearly-calendar-with-flexbox/</link>
					<comments>https://shkspr.mobi/blog/2023/04/responsive-yearly-calendar-with-flexbox/#comments</comments>
				<dc:creator><![CDATA[@edent]]></dc:creator>
		<pubDate>Fri, 28 Apr 2023 11:34:47 +0000</pubDate>
				<category><![CDATA[/etc/]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[flexbox]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[responsive]]></category>
		<guid isPermaLink="false">https://shkspr.mobi/blog/?p=45646</guid>

					<description><![CDATA[This blog has a calendar showing my yearly archives. It was in a table layout - which made sense when I first designed it - but had a few spacing niggles and was hard to make responsive.  Now, it behaves like this:    The code is relatively straightforward.  The HTML for the calendar looks like this:  &#60;div class=&#34;calendars&#34;&#62;     &#60;div class=&#34;calendar&#34;&#62;         &#60;div class=&#34;calendar-year&#34;&#62;2018&#60;/div&#62; …]]></description>
										<content:encoded><![CDATA[<p>This blog has a calendar showing my yearly archives. It was in a table layout - which made sense when I first designed it - but had a few spacing niggles and was hard to make responsive.</p>

<p>Now, it behaves like this:</p>

<p><video width="1024" height="576" src="https://shkspr.mobi/blog/wp-content/uploads/2023/04/Responsive-Calendar.mp4" mute="" loop="" autoplay=""></video></p>

<p>The code is relatively straightforward.  The HTML for the calendar looks like this:</p>

<pre><code class="language-html">&lt;div class="calendars"&gt;
    &lt;div class="calendar"&gt;
        &lt;div class="calendar-year"&gt;2018&lt;/div&gt;
        &lt;div class="calendar-month"&gt;January&lt;/div&gt;
        &lt;div class="calendar-month"&gt;February&lt;/div&gt;
        &lt;div class="calendar-month"&gt;March&lt;/div&gt;
        &lt;div class="calendar-month"&gt;April&lt;/div&gt;
        &lt;div class="calendar-month"&gt;May&lt;br&gt;&lt;/div&gt;
        &lt;div class="calendar-month"&gt;June&lt;/div&gt;
        &lt;div class="calendar-month"&gt;July&lt;/div&gt;
        &lt;div class="calendar-month"&gt;August&lt;/div&gt;
        &lt;div class="calendar-month"&gt;September&lt;/div&gt;
        &lt;div class="calendar-month"&gt;October&lt;/div&gt;
        &lt;div class="calendar-month"&gt;November&lt;/div&gt;
        &lt;div class="calendar-month"&gt;December&lt;/div&gt;
    &lt;/div&gt;

    &lt;div class="calendar"&gt;
        &lt;div class="calendar-year"&gt;2017&lt;/div&gt;
        &lt;div class="calendar-month"&gt;January&lt;/div&gt;
        &lt;div class="calendar-month"&gt;February&lt;/div&gt;
                ...
</code></pre>

<p>Repeat as many times as needed.</p>

<p>The CSS is slightly more tricky, but mercifully short:</p>

<p>The wrapper which holds all the calendars uses <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/flex-wrap"><code>flex-wrap</code></a>. This means there's no need to set explicit breakpoints - if there's no horizontal space, the calendar will move to the next row.</p>

<pre><code class="language-css">.calendars {
    display: flex;
    flex-wrap: wrap;
}
</code></pre>

<p>Each individual calendar item is <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns">a grid with three column layout</a>:</p>

<pre><code class="language-css">.calendar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    margin: .5em;
}
</code></pre>

<p>The "Year" at the top spans the first three columns. I find the <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column-end"><code>grid-column-...</code> syntax</a> confusing!</p>

<pre><code class="language-css">.calendar-year {
    grid-column-start: 1;
    grid-column-end: 4;
    text-align: center;
    outline: 1px black solid;
}
</code></pre>

<p>Finally, each individual month has a bit of internal padding and text formatting:</p>

<pre><code class="language-css">.calendar-month {
    text-align: center;
    padding: .25em;
    outline: 1px black solid;
}
</code></pre>

<p>I've used a basic black <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/outline"><code>outline</code></a>. Obviously, you can add whatever fancy CSS you like to make them look prettier.</p>
<img src="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/info/okgo.php?ID=45646&HTTP_REFERER=RSS" alt="" width="1" height="1" loading="eager">]]></content:encoded>
					
					<wfw:commentRss>https://shkspr.mobi/blog/2023/04/responsive-yearly-calendar-with-flexbox/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		<enclosure url="https://shkspr.mobi/blog/wp-content/uploads/2023/04/Responsive-Calendar.mp4" length="117070" type="video/mp4" />

			</item>
	</channel>
</rss>
