<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: The-architect </title>
    <description>The latest articles on DEV Community by The-architect  (@sethearchitect).</description>
    <link>https://dev.to/sethearchitect</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F783785%2F8373afe5-741b-4483-9edd-f84623b4ef7c.jpg</url>
      <title>DEV Community: The-architect </title>
      <link>https://dev.to/sethearchitect</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sethearchitect"/>
    <language>en</language>
    <item>
      <title># A Learner’s Exploration of  pseudo elements 2 - Applications: Custom counters with ::before and ::after</title>
      <dc:creator>The-architect </dc:creator>
      <pubDate>Mon, 31 Jan 2022 06:20:34 +0000</pubDate>
      <link>https://dev.to/sethearchitect/-a-learners-exploration-of-pseudo-elements-2-applications-custom-counters-with-before-and-after-1poo</link>
      <guid>https://dev.to/sethearchitect/-a-learners-exploration-of-pseudo-elements-2-applications-custom-counters-with-before-and-after-1poo</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8rBttf_w--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/43jow0zfhccayf4cttp3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8rBttf_w--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/43jow0zfhccayf4cttp3.png" alt="Finished result of card with custom counter using pseudo elements" width="415" height="478"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Finished result of card with custom counter using pseudo elements&lt;/em&gt;&lt;br&gt;
&lt;br&gt;&lt;br&gt;
A couple of months ago, I had worked up a pretty decent headache trying to create custom counters for some sections on my page. Recently, on exploring pseudo elements, I discovered a very easy way to achieve custom numbering using the ::before and ::after pseudo element and its been very breezy ever since.&lt;/p&gt;

&lt;p&gt;Diving in to how I created the sample above.&lt;/p&gt;

&lt;p&gt;The real star in helping us achieve this with pseudo elements is the content property. In my last exploration on this subject, I mentioned that the content property is the ray of sunshine that really helps pseudo elements shine. This particular functionality I’m covering has a heavy dependency on the content property.&lt;/p&gt;

&lt;p&gt;Setting up: I have a div container with four H4 elements listing some of the things we can do with ::before and ::after elements. This is not a list but we want to add counters to make it one.&lt;/p&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--K5Ri8rDc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/68m8baly19i72tmsbeiz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--K5Ri8rDc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/68m8baly19i72tmsbeiz.png" alt="HTML set up" width="880" height="459"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;HTML set up&lt;/em&gt;&lt;br&gt;
&lt;br&gt;&lt;br&gt;
Next we jump into CSS to make the magic happen in a simple couple of steps:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note that I have skipped the styling of the main div (.tip-card-body) to only focus on the custom list section.&lt;/em&gt;&lt;br&gt;
&lt;br&gt;&lt;br&gt;
&lt;/p&gt;
&lt;h3&gt;Step 1&lt;/h3&gt;
&lt;br&gt;&lt;br&gt;
First we declare the &lt;strong&gt;&lt;em&gt;counter-reset&lt;/em&gt;&lt;/strong&gt; property on the container element and set its value to any custom name of our choice, eg cool-counter. 

&lt;p&gt;Being a learner, I only just recently found out about this property and its application in achieving our custom list. It is used to initialize a &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Counter_Styles/Using_CSS_counters"&gt;CSS counter&lt;/a&gt; to a given value. It can be used for implicit counters as in ordered lists(ol) and unordered lists (ul), as well as for explicit counters as in author-specified counters (Custom counters like this one we’re making). &lt;/p&gt;

&lt;p&gt;As normal counters have a default value of 0, Passing a custom name as the counter-reset value basically tells CSS to set any counter with that name identifier to zero and then count from there. Learn more about the functionality and possibilities of the counter-reset property &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/counter-reset"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0OUjBc9s--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qah0k3jlb67cm1lpjotr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0OUjBc9s--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qah0k3jlb67cm1lpjotr.png" alt="Resetting the count on containing element." width="852" height="486"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Resetting the count on containing element&lt;/em&gt;&lt;br&gt;
&lt;br&gt;&lt;br&gt;
&lt;/p&gt;
&lt;h3&gt;Step 2&lt;/h3&gt;
&lt;br&gt;&lt;br&gt;
Next select the pseudo-element of the child elements to be numbered or counted, declare a '&lt;strong&gt;content-increment&lt;/strong&gt;' property on them and set the value to the name you passed to the counter-reset. Since these elements are contained within our custom defined counter which we specified with the counter-reset, the &lt;strong&gt;counter-increment&lt;/strong&gt; property on them will define how the counter’s value is increased or decreased based on their position within the counter. Also, considering we have a left hand counter, the ::before pseudo-element is ideal for this case.

&lt;p&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1nL-51xa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hgzyca0w1vyljr82dmi2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1nL-51xa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hgzyca0w1vyljr82dmi2.png" alt="Setting the counter increment value of the elements to be counted" width="852" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Setting the counter increment value of the elements to be counted&lt;/em&gt;&lt;br&gt;
&lt;br&gt;&lt;br&gt;
Since I want to count the H4 headers in this case, I’ve given all the H4 elements a common class of &lt;em&gt;count&lt;/em&gt; and targeted the ::before pseudo element of that class. This applies the counter-reset value specified in step 1 to all the spotlighted elements but at the stage, no visible change would’ve happened yet. Fret not. we’ve just got to turn the lights on. That leads us to step 3&lt;/p&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--X6kp1Ssn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mkx372agbl30cv042enq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--X6kp1Ssn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mkx372agbl30cv042enq.png" alt="Card after adding the counter-reset and counter-increment properties" width="401" height="464"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Card after adding the counter-reset and counter-increment properties&lt;/em&gt;&lt;br&gt;
&lt;br&gt;&lt;br&gt;
&lt;/p&gt;
&lt;h3&gt;Step 3&lt;/h3&gt;
&lt;br&gt;&lt;br&gt;
Recall from the &lt;a href="https://dev.to/sethearchitect/a-learners-exploration-of-pseudo-elements-intro-5bid"&gt;last article&lt;/a&gt; when I said the content property is the breath of life that brings our pseudo elements to life? this is a classic case in point.

&lt;p&gt;In this step, we declare the content property on the &lt;em&gt;.count::before&lt;/em&gt; element, and set its value to a counter function passing the name we specified to the counter-reset property in step one as its parameter. Boom! the magic happens&lt;/p&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TzFEv5zh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1qgifrnv290k9flvziki.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TzFEv5zh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1qgifrnv290k9flvziki.png" alt="declaring the content property" width="852" height="486"&gt;&lt;/a&gt;&lt;br&gt;
&lt;br&gt;&lt;br&gt;
Now, note that its not necessary to declare these properties in the particular order I have followed for this to work. I’ve only done so to highlight the role of the content property in CSS pseudo shadow magic (&lt;em&gt;Forgive my corny reference but It sounded so cool in my head&lt;/em&gt; 😅).&lt;/p&gt;

&lt;p&gt;What you should have now: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4YltCc63--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h9xo2j9o54lzwfd8jux5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4YltCc63--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h9xo2j9o54lzwfd8jux5.png" alt="Numbering becomes visible after the content property is declared" width="421" height="475"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Numbering becomes visible after the content property is declared&lt;/em&gt;&lt;br&gt;
&lt;br&gt;&lt;br&gt;
We have our counters visible now but it’s not looking quite awesome is it? Well then, on to step 4.&lt;br&gt;
&lt;br&gt;&lt;/p&gt;


&lt;h3&gt;Step 4&lt;/h3&gt;
&lt;br&gt;&lt;br&gt;
Go crazy!&lt;br&gt;&lt;br&gt;
You can apply other styles to the ::before element to have it looking the exact way you want. For the sample card we’ve been using, these are the rest of the styles I’ve used:

&lt;p&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PRWg3Kan--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tiswhbeouzqdspe9uc6u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PRWg3Kan--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tiswhbeouzqdspe9uc6u.png" alt="Other visual styles in creating the final result" width="852" height="1194"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Other visual styles in creating the final result&lt;/em&gt;&lt;br&gt;
&lt;br&gt;&lt;br&gt;
If you’re following my example, you might have to tweak the positioning values as necessary because other style factors like the size of your card, margins and paddings, font-sizes and family you use might make your overall card bigger or smaller than mine. &lt;/p&gt;

&lt;p&gt;To see the exact styles I’ve used, checkout the build on &lt;a href="https://codepen.io/lonelyluci/pen/JjOGoyZ?editors=0100"&gt;codepen&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Thanks for reading!&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>tutorial</category>
      <category>css</category>
      <category>html</category>
    </item>
    <item>
      <title>A Learner’s Exploration of Pseudo Elements (Intro)</title>
      <dc:creator>The-architect </dc:creator>
      <pubDate>Mon, 24 Jan 2022 22:48:47 +0000</pubDate>
      <link>https://dev.to/sethearchitect/a-learners-exploration-of-pseudo-elements-intro-5bid</link>
      <guid>https://dev.to/sethearchitect/a-learners-exploration-of-pseudo-elements-intro-5bid</guid>
      <description>&lt;h2&gt;
  
  
  ::before and ::after pseudo elements
&lt;/h2&gt;



&lt;p&gt;I think of the ::before and ::after pseudo elements as the shadows of HTML elements. But unlike human shadows, they get to have a life of their own.&lt;/p&gt;

&lt;p&gt;Pseudo elements being so independent while being still totally dependent on their host elements is  very interesting. Like the name suggests, these are not actual elements but their application and ability are still very extensive regardless.&lt;/p&gt;

&lt;p&gt;This is a curious exploration about what they can do, why they are used and perhaps most of all, how to know when to use them. &lt;/p&gt;

&lt;p&gt;The ::before and ::after elements are used to insert some content &lt;strong&gt;&lt;em&gt;before&lt;/em&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;em&gt;after&lt;/em&gt;&lt;/strong&gt; the content of an element. Note that this insertion does not happen before/after the element but before/after &lt;strong&gt;&lt;em&gt;the content&lt;/em&gt;&lt;/strong&gt; it contains &lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--X6oyT06L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1188ofvrz9t2p9h8klxb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--X6oyT06L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1188ofvrz9t2p9h8klxb.png" alt="A paragraph element showing its ::before and ::after pseudo-elements" width="762" height="94"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;A paragraph element showing its ::before and ::after pseudo-elements&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
These two elements can be used &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To add &lt;em&gt;anonymous content&lt;/em&gt;** to elements,&lt;/li&gt;
&lt;li&gt;For decorative design without adding extra markup to the document,&lt;/li&gt;
&lt;li&gt;To custom style some default HTML elements like certain input fields, and&lt;/li&gt;
&lt;li&gt;To create custom shapes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This means that these shadow elements can be used almost anywhere save for a couple exceptions like with &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Replaced_element"&gt;replaced elements&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If ::before and ::after are living shadows, their ‘content’ property is the breath of life that gives them essence. Without setting the content property to a value, none of the styles applied to the pseudo elements will be rendered on screen.&lt;/p&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KGiXa7oT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hfg0q9mh7w8kle670tyj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KGiXa7oT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hfg0q9mh7w8kle670tyj.png" alt="Setting up your Pseudo elements for success" width="880" height="821"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Setting up your Pseudo elements for success&lt;/em&gt;&lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;p&gt;Once the content property has been set, your pseudo elements can be styled to do many things pretty much like any other HTML element. Although the content property is just fine being set to an empty string, there are some other values that can be passed to the property to achieve interesting results. I will explore some of those cases in subsequent articles in this series.&lt;/p&gt;

&lt;p&gt;Most of the time, setting the position property of the elements to absolute and making the main element a relatively positioned container will be absolutely necessary. This makes it easier to control exactly how our pseudo elements are positioned. &lt;/p&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qAJgopem--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nycxkmm7j1p1bty78a22.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qAJgopem--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nycxkmm7j1p1bty78a22.png" alt="Adding position properties for more control of placements" width="822" height="856"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
Once this is set, we can use the inset positioning properties (top, bottom, left and right) to explicitly define the exact position of our pseudo elements.&lt;/p&gt;

&lt;p&gt;Further articles in my Learner’s exploration series will cover some of the various interesting things we can do with ::before and ::after pseudo elements and the amazing ways we can begin to apply them in making our little corner of the web just a little bit more awesome!&lt;/p&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
** &lt;em&gt;I understand anonymous content as content that is visually rendered in the browser but does not have a corresponding markup element.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>css</category>
      <category>codenewbie</category>
      <category>tutorial</category>
      <category>webdev</category>
    </item>
    <item>
      <title>A Learner's Exploration of CSS Grid (01)</title>
      <dc:creator>The-architect </dc:creator>
      <pubDate>Mon, 17 Jan 2022 12:29:51 +0000</pubDate>
      <link>https://dev.to/sethearchitect/a-beginners-exploration-of-css-grid-01-1h3</link>
      <guid>https://dev.to/sethearchitect/a-beginners-exploration-of-css-grid-01-1h3</guid>
      <description>&lt;p&gt;Work with CSS grids a couple of times and you’ll get the impression that it is a relatively easy concept to grasp - at least for simple to moderately complex layouts.  And for the most part, it kind of is.&lt;/p&gt;

&lt;p&gt;An understanding of the basic structural rules makes it easy to jump right into defining interesting layouts and arrangements. But even after using grids for a couple of layouts, I still have that tangible nagging that there is still so much to grids below the hood. So here’s going to be a series of explorations to find out. &lt;/p&gt;

&lt;p&gt;While this is an article about grid, it is not intended to serve as an exhaustive coverage of the concept, or even as a tutorial for that matter. It is simply a documentation of observations I’ve made in the little while since I started working with CSS grids. That said, lets get into it.&lt;/p&gt;

&lt;p&gt;An advice from the noble CSS master Kevin Powell, which has and still proves to be useful so far, is to always start with a simple set up. On a grid container, all you will usually ad necessarily need is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;declare the display as a grid&lt;/li&gt;
&lt;li&gt;Define the column specifics - Number of tracks, sizes of tracks and flexibility&lt;/li&gt;
&lt;li&gt;Define the gutter spacing (If your layout requires that).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1gOfqMU1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9h4f3acfx899wm27xlnb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1gOfqMU1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9h4f3acfx899wm27xlnb.png" alt="Setting up a simple grid container" width="856" height="596"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This example snippet initializes a simple grid with two columns that responsively sizes and redistributes to fill the available space within the container. The &lt;strong&gt;&lt;em&gt;fr&lt;/em&gt;&lt;/strong&gt; unit was probably the last unit I got comfortable with for no real reason other than fear of the unknown. But I’ve now found it to be the most comfortable unit to default to, especially when the grid to be created has no particular explicit constraints.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;&lt;em&gt;fr&lt;/em&gt;&lt;/strong&gt; unit basically directs CSS to take the available free (unassigned) space in the container and proportionately divide it across the number of declared tracks. In my example, the available space within the container is divided into two equal tracks. The equality here is only because all the values preceding the &lt;strong&gt;&lt;em&gt;fr&lt;/em&gt;&lt;/strong&gt; units are equal; to 1.&lt;/p&gt;

&lt;p&gt;The proportion of an &lt;strong&gt;fr&lt;/strong&gt; sized cell track is weighted by the number value preceding the &lt;strong&gt;fr&lt;/strong&gt; unit. It’s observed size variation is relative to the available space, and the value of any other &lt;strong&gt;fr&lt;/strong&gt; sized cell track in the container’s grid declaration. Basically, unless there is another &lt;strong&gt;fr&lt;/strong&gt; sized cell track in the grid cell track declaration, as well as a difference between the &lt;strong&gt;fr&lt;/strong&gt; values prefix, no proportional variation in size is observed.  &lt;/p&gt;

&lt;p&gt;Just one cell track sized with the &lt;strong&gt;fr&lt;/strong&gt; unit used along side other tracks sized with relative or absolute units will not display the proportional flexibility you might expect it to.&lt;/p&gt;

&lt;p&gt;This:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eEFP0rp3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jqmqke45mym3wwzsxc4t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eEFP0rp3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jqmqke45mym3wwzsxc4t.png" alt="Template columns defining two column tracks sized to 1fr and auto" width="840" height="410"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;will be visually identical to this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---5yNv2Zg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/flb1vxwcswhmuou41np2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---5yNv2Zg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/flb1vxwcswhmuou41np2.png" alt="Template columns defining two column tracks sized to 4fr and auto" width="840" height="410"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;and this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cHA83Hza--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/huvp5t2k05l1gc5amxh3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cHA83Hza--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/huvp5t2k05l1gc5amxh3.png" alt="Template columns defining two column tracks sized to 4fr" width="824" height="410"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;is the same as this: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--teOwyL0O--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zr2y3mbvixalcn31ebw2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--teOwyL0O--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zr2y3mbvixalcn31ebw2.png" alt="Template columns defining two column tracks sized to 1fr" width="824" height="410"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To understand why it is mostly possible to have a fun grid rodeo without ever declaring the template rows, we have to appreciate the functionality of grids to have &lt;strong&gt;implicit&lt;/strong&gt; and &lt;strong&gt;explicit&lt;/strong&gt; cell tracks. In simple talk, there are grid cells you create and control (Explicit cells) and then there are cells the grid module automatically creates for you on the fly. Those automatically created cells are implicit grid cells. &lt;/p&gt;

&lt;p&gt;Unless an explicit rule is declared to modify it’s behavior, CSS grid by default is designed to automatically create new cells to layout content that does not fit into the explicitly created grid, or content that may not yet have been added to the container at the  moment of declaration.&lt;/p&gt;

&lt;p&gt;Using our simple grid example, our container only has two column tracks. When those tracks are declared, all the child elements contained within our container will be automatically arranged to fill those created cells. the default arrangement order follows the normal document flow from the html.&lt;/p&gt;

&lt;p&gt;So say we have 6 div children within our grid container, each of them automatically get placed on the grid we’ve created. Now since we’ve only defined our template columns, CSS grid intuitively creates a row with a default size of &lt;strong&gt;auto&lt;/strong&gt; and because we have only two columns defined, the first two children get placed into the cells . Just as the first row was automatically or &lt;strong&gt;implicitly&lt;/strong&gt; generated, a second row is generated to accommodate the next two children, then a third row for the next two and now all six child divs have cells over their heads. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lwZMfSkc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bb7cou0tn5d0d1ktnay7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lwZMfSkc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bb7cou0tn5d0d1ktnay7.png" alt="Demonstration of implicit grid action with auto-generated row tracks" width="880" height="170"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This behavior to wrap the outstanding children into auto generated rows is simply because grids default design is to wrap elements to rows. &lt;/p&gt;

&lt;p&gt;if our original grid structure only declared the template rows instead of columns as we have done, the outstanding children will still get wrapped onto new rows.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--socjDtW7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zdiu3o8gap64891flvil.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--socjDtW7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zdiu3o8gap64891flvil.png" alt="Container grid defining only template rows" width="806" height="596"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Nr_If4Gh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zl8dqxsxgmvt88z19av5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Nr_If4Gh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zl8dqxsxgmvt88z19av5.png" alt="Display of grid defined by code snippet above showing implicit row action" width="880" height="308"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Depending on your layout objectives, This default wrap behavior can be modified by using the grid-auto-flow property and setting it to column. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dmiClPOz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w2lgnyw2x9tbjvgd1807.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dmiClPOz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w2lgnyw2x9tbjvgd1807.png" alt="container grid declaration with only template rows set and  user defined grid-auto-flow direction set to column" width="806" height="632"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The code above will define a grid where the child elements are arranged from top to bottom first before they’re wrapped to the next column. Numbering our child divs demonstrates this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gA6ag1uD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zthwhtrzyoaa8naa9lej.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gA6ag1uD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zthwhtrzyoaa8naa9lej.png" alt="Display of the grid defined with template rows and user defined grid-auto-flow direction set to column" width="880" height="122"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now say we change the default wrap direction of a grid declared with only template columns, the implicit layout created with look like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--f50_itEu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xg2oqxikftxdu5sjmh1q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--f50_itEu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xg2oqxikftxdu5sjmh1q.png" alt="Display of the grid defined with template columns and user defined grid-auto-flow direction set to column" width="880" height="149"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LTUtOMEi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dme3jaxifnlsjoukqgjm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LTUtOMEi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dme3jaxifnlsjoukqgjm.png" alt="container grid declaration with only template columns set and  user defined grid-auto-flow direction set to column" width="840" height="632"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Because implicitly created cells are sized to &lt;strong&gt;auto&lt;/strong&gt; by default, the auto columns are all sized to accommodate the default div size. The lorem ipsum content inside the child divs wrap on to newlines simply because my available viewport didn’t let them stretch. Naturally, the Grid module first assigns the available container space to the tracks with units other than &lt;strong&gt;&lt;em&gt;fr,&lt;/em&gt;&lt;/strong&gt; then divvies what is left to the &lt;strong&gt;&lt;em&gt;fr&lt;/em&gt;&lt;/strong&gt;-sized tracks - even though they were the explicitly declared tracks.&lt;/p&gt;

&lt;p&gt;That snip also helps us on to another observation to reinforce a point we made earlier: since our grid structure declaration only defined the template columns, even the single row in which our child elements are placed was implicitly created by CSS grid. This mean its default height value is also &lt;strong&gt;auto.&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;That is why it stretches to accommodate the content of the divs on the 1fr columns which have been squished into multiple lines.  Say we decide to define an explicit row with our own height value, if that height is less than enough to contain the squished content, we will end up with a situation where the children overflow the grid on the column axis.&lt;/p&gt;

&lt;p&gt;For example, this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FxdrD-02--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0k72c79uddh0fllrolq7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FxdrD-02--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0k72c79uddh0fllrolq7.png" alt="container grid declaration with only template columns set, user defined template row height and  user defined grid-auto-flow direction set to column" width="840" height="670"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;will result in this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QvzQOZQM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fqljcgsqs84hxh6m1dxn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QvzQOZQM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fqljcgsqs84hxh6m1dxn.png" alt="Display showing overflow resulting from code snippet above" width="880" height="124"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This begins to clarify why it is advisable to only define the column tracks on the grid, and let CSS implicitly make our lives easier with its default grid-template-rows and grid-auto-flow property values. Unless otherwise demanded, this Just a way to easy grid living.&lt;/p&gt;

&lt;p&gt;This article has only covered limited case scenarios involving grid container properties with basically none or only very cursory touches on grid child properties. Subsequent articles will explore child properties and behaviors as well as other container scenarios.&lt;/p&gt;

</description>
      <category>css</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>A Learner's Exploration of CSS Translate</title>
      <dc:creator>The-architect </dc:creator>
      <pubDate>Mon, 17 Jan 2022 11:57:18 +0000</pubDate>
      <link>https://dev.to/sethearchitect/a-learners-exploration-of-css-translate-508m</link>
      <guid>https://dev.to/sethearchitect/a-learners-exploration-of-css-translate-508m</guid>
      <description>&lt;h2&gt;
  
  
  case study: Agba Akin’s CSS clock.
&lt;/h2&gt;

&lt;p&gt;Link to reference: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://akinolaakeem.com/a-beautiful-wall-clock-made-with-only-neumorphism-css/"&gt;A Beautiful wall clock made with only Neumorphism CSS - Akinola Abdulakeem&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I came across this project on Twitter and had made a note to replicate it but when I came around to it, I realized just reading the code and replicating it won’t satisfy me. I wanted to understand the engine beneath the hood - and that led to this article. &lt;/p&gt;

&lt;p&gt;In this article and the others that will follow, I will try to understand the thought and build of this nice project by shedding particular focus on the  CSS concepts it applies to achieve its make and functionality. The goal is not just to be able to build one clock, but to understand the concepts and their applications so as to be able to build several other clocks, as well as other interesting things.&lt;/p&gt;

&lt;p&gt;Being a learner, the animation was mighty cool but The first challenge that really got my attention was the arrangement of the numbers - especially after seeing the HTML. So here’s to understanding the translate() function of the CSS transform property.&lt;/p&gt;

&lt;p&gt;The translate() function can be passed as a value  to the CSS transform property. The function repositions an element in the horizontal and vertical direction.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/translate()"&gt;MDN docs&lt;/a&gt; describes it as being defined by a two dimensional vector. This simply means it is defined along two directions. It uses the  graph X and Y axis to compute the movement direction of the element it is applied on.  &lt;/p&gt;

&lt;p&gt;The two values the function takes as parameters act as coordinates to determine how the element will move and be located on the horizontal (x) and vertical (y) axis.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yJnv2hnA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9i0pawpwqme0dcmziz0g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yJnv2hnA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9i0pawpwqme0dcmziz0g.png" alt="Code snippet showing a CSS transform declaration" width="880" height="479"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For example, The div with class “inside” will be &lt;em&gt;translated&lt;/em&gt; 20px on the horizontal axis and 10px on the vertical axis. Without any prior positioning, the default origins as you may have assumed is 0,0 but unlike in our graphs from math class, here, we start from the top right corner of the container.&lt;/p&gt;

&lt;p&gt;Before any transformation is applied on the element&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sJ9mbKg9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rm4wk0n6kwdi8yrgt7o7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sJ9mbKg9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rm4wk0n6kwdi8yrgt7o7.png" alt="Element before any transformation is applied" width="590" height="575"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And after the code snippet above is applied&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UC_6bjaH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g2qwesydvmdfzwrve29b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UC_6bjaH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g2qwesydvmdfzwrve29b.png" alt="Element after transformation is applied" width="585" height="576"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;While the code snippet above uses two parameters, the translate() function can also take only a single value. The value parameters have to be a length or percentage value.&lt;/p&gt;

&lt;p&gt;When a single value is passed to the translate() function, it uses it to compute only the movement on the horizontal axis while the vertical (Y) axis is defaulted to 0.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EQkDGIl7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vieifdpvfvlqrnk7ihlq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EQkDGIl7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vieifdpvfvlqrnk7ihlq.png" alt="Code snippet showing translate function with only one parameter" width="840" height="632"&gt;&lt;/a&gt;&lt;br&gt;
transform: translate(50px) and &lt;/p&gt;

&lt;p&gt;transform: translate(50px, 0px) will yield the same result:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fj_jINiz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1ula9tw6kcv197pm7b1c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fj_jINiz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1ula9tw6kcv197pm7b1c.png" alt="Resulting effect of single parameter translate() on element" width="582" height="574"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When the translate function is passed a percentage value, the percentage will relate to the width of the element being transformed. Say we pass a value of 50% to our translate function, the positioned element will be translated a distance equal to 50% of its own width.&lt;/p&gt;

&lt;p&gt;To demonstrate this;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FwaUq3__--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6zme26pmcpjtv5mkpcnf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FwaUq3__--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6zme26pmcpjtv5mkpcnf.png" alt="Code snippet showing translate function passed with single percentage parameter" width="772" height="520"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;this code snippet will result in this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RP7x1R7o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jmlona3j82wt996hhuhv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RP7x1R7o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jmlona3j82wt996hhuhv.png" alt="Element moves by 50% its own width" width="573" height="568"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If we add another Div of the exact same size but without any transformation applied to it as a reference, and set the translate parameter of our first div to 100%, we see our translated div moves by exactly the width of the second div&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nuiTN6VP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gdn5y96bw7wh5dask74y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nuiTN6VP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gdn5y96bw7wh5dask74y.png" alt="Percentage translation demonstrated against a non transformed element" width="575" height="569"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So whenever a percentage parameter value is passed to the translate() function on an element, the distance it computes is the percentage of its own total width.&lt;/p&gt;

&lt;p&gt;When double parameter values are passed to the translate() function, they define the horizontal and vertical vector in that particular order - The first value translates the element on the horizontal (x) axis, while the second value moves the element on the vertical (Y) axis.&lt;/p&gt;

&lt;p&gt;The values passed can both be length values, percentage values or a mixture of length and percentage values. When both values are percentage values, the first value relates to the width of the referenced element, while the second value refers to the height of the referenced element.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6gA_yjaW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6kplk7kzuyd66zp5ysgo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6gA_yjaW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6kplk7kzuyd66zp5ysgo.png" alt="Code snippet with two percentage parameters passed to the translate function" width="840" height="520"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The code snippet will move the div by a distance equal to 50% its own width on the horizontal axis, and a distance equal to 30% its own height on the vertical axis.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lC5T5YKf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w1aly38saqiehef736yk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lC5T5YKf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w1aly38saqiehef736yk.png" alt="Image demonstrating translate effect of code snippet above" width="584" height="579"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The width and  height of our sample div is 15em (240px) and so its translated by 50% * 15em on the X-axis, and 30% * 15em on the Y-axis.&lt;/p&gt;

&lt;p&gt;Note that the translate() function positions elements without altering their position in the normal document flow.&lt;/p&gt;

&lt;p&gt;Now to the actual arrangement of the  numbers.&lt;/p&gt;

&lt;p&gt;Knowing how the translate function works, all that’s left is determining the values to define our position coordinates. The case study example first brings all the numbers to the center of the clock and then uses translate() to position them around the invisible round edge. The declarations of the code block that brings the numbers to the center is shown below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mpA1egRk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0ojaau9zrsvyyfseky52.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mpA1egRk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0ojaau9zrsvyyfseky52.png" alt="Code snippet showing declaration to center numbers within container" width="654" height="596"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The (...) represents all the other code contained within this block. for the purpose of clarity and simplicity, I’m only sticking to what’s necessary four our current focus.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If the elements are not exactly centered by the code snippet above, make sure to check that the elements margins are reset to zero. The offset defined by default margins from the element styles can throw the elements off.&lt;/p&gt;

&lt;p&gt;Next is positioning the numbers around the center point to appear like they radiate from the point. The translate() function comes in here but to get the parameter values that will serve as coordinates, we have to do a little geometry first.&lt;/p&gt;

&lt;p&gt;The numbers are arranged around a circular path and their positions are points that can be mapped relative to the origin of the circle, its radius, and angle of each segment as represented below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZRx8UZUc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/30eiot7c7cw4oa5monk4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZRx8UZUc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/30eiot7c7cw4oa5monk4.png" alt="Segmented circle showing number positions along circumference" width="396" height="370"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These points are used to determine the vertical and horizontal distances each number needs to be translated to.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cU7is2xW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rincasivjra0pqwbnhnj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cU7is2xW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rincasivjra0pqwbnhnj.png" alt="Coordinates mapped from the relationship between the circle origin, radius and angle of rotation" width="359" height="350"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As is probably obvious from the above figure, the height and widths of the colored rectangles results in the X and Y values for each number’s position. 12 and 3 have 100% movement on the Y-axis and 0 movement on the X-axis and 100% movement on the X-axis and 0 movement on the Y-axis respectively.&lt;/p&gt;

&lt;p&gt;the transform declaration becomes:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DDqeGX62--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3ljx5svdxgid0spaog9i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DDqeGX62--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3ljx5svdxgid0spaog9i.png" alt="code snippet of template transform declaration" width="772" height="558"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;where &lt;/p&gt;

&lt;p&gt;n = the occurring order of the child element within its container, &lt;/p&gt;

&lt;p&gt;x = distance translated on the x-axis&lt;/p&gt;

&lt;p&gt;y = distance translated on the y-axis&lt;/p&gt;

&lt;p&gt;The ‘:nth-child(n) syntax’ is a pseudo selector that points to the number &lt;em&gt;n&lt;/em&gt;  child of a parent element&lt;/p&gt;

&lt;p&gt;I used a circle of 345px in diameter and the coordinate values are as follows:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8gJ-o-v6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7lhk8hyecl9o94wf3ioc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8gJ-o-v6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7lhk8hyecl9o94wf3ioc.png" alt="code snippet of transform declaration using position data from circle geometry" width="351" height="313"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All that is needed now is to substitute these values with the translate() parameters accordingly. Note that I’ve only done one quadrant of the circle. This is because these values will be same for all the other quadrants although there is a catch - that draws attention to the next point to note. &lt;/p&gt;

&lt;p&gt;You may have noticed the counter intuitive use of the negative symbol, especially if you are the math-y type. This is because by default, the movement of the translate() function is &lt;strong&gt;top-bottom&lt;/strong&gt; on the Y-axis and &lt;strong&gt;left-right&lt;/strong&gt; on the X-axis. Since the movement of the numbers starts from the center of the circle, the default movement of the &lt;em&gt;positive- y&lt;/em&gt; will be down  and the &lt;em&gt;positive- x&lt;/em&gt; will move left. This default movement is easily modified by using negative values where necessary just as has been done for the Y value of 12.&lt;/p&gt;

&lt;p&gt;Positioning of the other numbers in the other quadrants is simply achieved by switching the negative values appropriately between  x and y. For example, to position the number 6, my transform declaration will look like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pdoFMyRT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lp8equra7x9zqt8scflv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pdoFMyRT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lp8equra7x9zqt8scflv.png" alt="Example of transform declaration with actual values substituted in" width="880" height="552"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NB:&lt;/strong&gt; The y-value may differ depending on the radius of the circle you use.&lt;/p&gt;

&lt;p&gt;Further Explorations will try to understand some of the other CSS concepts that give the clock its functionality.&lt;/p&gt;

</description>
      <category>codenewbie</category>
      <category>css</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
