<?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>Forem: Marciano Schildmeijer</title>
    <description>The latest articles on Forem by Marciano Schildmeijer (@marcianosr).</description>
    <link>https://forem.com/marcianosr</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%2F185963%2F21873c98-a6f0-4d77-a8df-6cface0421fe.jpeg</url>
      <title>Forem: Marciano Schildmeijer</title>
      <link>https://forem.com/marcianosr</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/marcianosr"/>
    <language>en</language>
    <item>
      <title>My gamedev side road journey as a frontend developer - week 1</title>
      <dc:creator>Marciano Schildmeijer</dc:creator>
      <pubDate>Wed, 26 May 2021 12:14:50 +0000</pubDate>
      <link>https://forem.com/marcianosr/my-gamedev-side-road-journey-as-a-frontend-developer-week-1-34lp</link>
      <guid>https://forem.com/marcianosr/my-gamedev-side-road-journey-as-a-frontend-developer-week-1-34lp</guid>
      <description>&lt;p&gt;Welcome readers to my side project diary!&lt;/p&gt;

&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;I'd like to share the story and thoughts so far I had from the start up until the end of the side project I'm working on. The biggest reasons I start this, is to give this process more structure and also to help other devs that are feeling the exact same as I did/do. &lt;/p&gt;

&lt;p&gt;A little information about my younger self: Writing about parts of my life is very valuable. At age of 10, I started writing a small newspaper of a few pages 2 time a week. I did this, because my parents wanted to help me improve my language. At that age, it was not my favorite thing to do, because I loved gaming and didn't care much. I still kept writing 2 times a week, though with some push from my parents here and there, for 7 years. And I am happy to I did, because it is like a timemachine for me. I can recall much easier what I did, and where I was, which is fun on itself in my opinion. The real message I want to tell that writing is really valuable if you want to learn new things. That's why I like to talk about my side project I'm working on.&lt;/p&gt;

&lt;h3&gt;
  
  
  Earlier side projects
&lt;/h3&gt;

&lt;p&gt;I'm working as a frontend developer for 4 years now. Most of the times, I still feel like an imposter, like many of us frontend developers do. I also did a lot of unfinished side projects, which I think I handled very inefficiently in my eyes when I look back. I "flew" in the project with a vague global idea of what I wanted, and just started building. Building a few simple features worked out okay. But working on a fairly complex side project needed some more guides and structure. I didn't have such. I kept forgetting what I wanted to build exactly and for what, then lost interest in the project and value of the idea, while the projects were also far too hard and big at that time. Most certainly without any kind of structure. &lt;/p&gt;

&lt;h3&gt;
  
  
  The game side project
&lt;/h3&gt;

&lt;p&gt;So after a warehouse full of failed and unfinished side projects, I felt bad. I need projects that challenge me to learn the things I want to get good at, and something I really like to build. I struggled with this a lot. Why build something that already exists? And what does it solve? Well, I should keep in mind that it solves one of my great goals: Building a cool app/website that also allows me to get me more knowledge of programming subjects. &lt;/p&gt;

&lt;p&gt;Then I started "metselen". &lt;/p&gt;

&lt;h3&gt;
  
  
  Enter "metselen" the game
&lt;/h3&gt;

&lt;p&gt;So I started this game side project out of nowhere on a Tuesday evening. I remembered this small game that I was playing in primary school, and I wanted to rebuild it and extend it with my own ideas. But first, I started writing exactly what came up into my mind, and made little user stories out of that. This helped me to setup a small structure, so when I returned to this project later, I knew where I left off, and what/why I wanted to build this again. Very useful. &lt;br&gt;
I also introduced talking about this project on a weekly basis with a colleague of mine, who helped me up to speed and still encourages me to work on it, because he is interested in the game and the steps I take. &lt;/p&gt;

&lt;p&gt;"Metselen" is a dutch word which actually means bricklaying. In short, the game works like this: You answer multiplication sums and for each correct answer, you'll get a brick in a given time. &lt;/p&gt;

&lt;p&gt;An earlier version of the game: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QzX4cQMr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/goo6ysr4fmy3e4d4x86o.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QzX4cQMr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/goo6ysr4fmy3e4d4x86o.gif" alt="metselen"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Basic functionalities are working. I was happy! &lt;/p&gt;

&lt;p&gt;Next week I'll share the progress and some other dev hurdles I needed to take.&lt;/p&gt;

&lt;p&gt;See you next week!&lt;/p&gt;

</description>
      <category>gamedev</category>
      <category>javascript</category>
      <category>css</category>
      <category>react</category>
    </item>
    <item>
      <title>How the CSS stacking context works</title>
      <dc:creator>Marciano Schildmeijer</dc:creator>
      <pubDate>Tue, 21 May 2019 00:00:00 +0000</pubDate>
      <link>https://forem.com/kabisasoftware/how-the-css-stacking-context-works-4pag</link>
      <guid>https://forem.com/kabisasoftware/how-the-css-stacking-context-works-4pag</guid>
      <description>&lt;p&gt;Anyone who has ever worked with HTML and CSS may have heard of, or worked with the z-index property. What it does is pretty straightforward: It allows you to manage the stacking order of so called “positioned” HTML elements. Anything with a higher z-index number should always appear above elements with a lower z-index. However, sometimes you end up in situations where the z-index property doesn’t seem to have any effect at all and it isn’t that straightforward as it seems. In these situations it’s likely that you’re dealing with differences in &lt;strong&gt;the stacking context.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Default rules of stacking elements
&lt;/h3&gt;

&lt;p&gt;When no positioned elements are applied, the basic rules of the element stacking order is as follows: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When the root element  is rendered, it creates the &lt;strong&gt;root (or global) stacking context.&lt;/strong&gt; &lt;/li&gt;
&lt;li&gt;Followed by &lt;strong&gt;non-positioned&lt;/strong&gt; elements, where the &lt;strong&gt;position&lt;/strong&gt; value is not specified. The position value defaults to &lt;strong&gt;static&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Followed by &lt;strong&gt;positioned&lt;/strong&gt; elements, which are all elements with a position property other than &lt;strong&gt;static&lt;/strong&gt;, such as &lt;strong&gt;fixed&lt;/strong&gt;, &lt;strong&gt;absolute&lt;/strong&gt;, &lt;strong&gt;sticky&lt;/strong&gt; or &lt;strong&gt;relative&lt;/strong&gt;. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All respecting the order they are declared in the document.&lt;/p&gt;

&lt;h3&gt;
  
  
  Stacking with positioned elements
&lt;/h3&gt;

&lt;p&gt;When elements are positioned, they appear above non-positioned elements. Many layouts consist out of positioned elements where controlling the stacking order of elements is required. A common use case is for instance a modal you want to show above the normal content of your page. To control the stacking order, z-index is used on &lt;strong&gt;positioned&lt;/strong&gt; elements. Z-index won’t work on non-positioned elements. Applying the position properties with values like &lt;strong&gt;fixed and sticky&lt;/strong&gt;, or &lt;strong&gt;absolute and relative&lt;/strong&gt; in combination with a &lt;strong&gt;z-index&lt;/strong&gt; value other than &lt;strong&gt;auto&lt;/strong&gt;, will create a &lt;strong&gt;new local stacking context&lt;/strong&gt;. &lt;/p&gt;

&lt;h3&gt;
  
  
  Taking (local) stacking contexts into account
&lt;/h3&gt;

&lt;p&gt;Things get more tricky now. When stacking contexts are created on an element, that element will become a root stacking context element for its children elements. Documents can have many stacking contexts, so it is not rare to have stacking contexts inside other stacking contexts. The problem this creates is that children of the newly created stacking context won’t be able to render on top of an element in a different stacking context. Never ever. Even when the children will become positioned elements. Even with z-index: 999999;.&lt;/p&gt;

&lt;p&gt;To overcome this problem, you can swap out these child elements in the current DOM hierarchy and bring them to the same level of the root stacking context ( element). Positioned sibling elements &lt;strong&gt;can&lt;/strong&gt; be ordered with the z-index property. However in more complex DOM structures where many elements live inside each other, this may include some rework of your CSS or even JavaScript and may be more complex. &lt;/p&gt;

&lt;p&gt;&lt;a href="//images.ctfassets.net/8v4g74v8oew0/1v5NjZO4FWzct7kscMVEEx/50a42cfc2c39aecd97fe7eeb72d4855e/image1.png" class="article-body-image-wrapper"&gt;&lt;img src="//images.ctfassets.net/8v4g74v8oew0/1v5NjZO4FWzct7kscMVEEx/50a42cfc2c39aecd97fe7eeb72d4855e/image1.png" alt="image1"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Implicit creation of stacking context
&lt;/h3&gt;

&lt;p&gt;Another important thing to mention is that there are more implicit ways of how stacking contexts are created. Earlier in this post, I mentioned one way of how stacking contexts are created. There are more CSS properties that create their own stacking contexts implicitly. Unfortunately there is no clear way to see when a stacking context is created at a glance. However, there is &lt;a href="https://chrome.google.com/webstore/detail/z-context/jigamimbjojkdgnlldajknogfgncplbh"&gt;a cool Chrome plugin&lt;/a&gt; that can be a bit of a help when identifying stacking context elements. It basically collects the properties that cause the stacking context for each element and outputs information about the element like this (shown in the right column, Z-index tab): &lt;/p&gt;

&lt;p&gt;&lt;a href="//images.ctfassets.net/8v4g74v8oew0/4E0Had9zB5iRAGQakCuJo5/baa15b2474df6ea9c8b873ca0940156f/image2.png" class="article-body-image-wrapper"&gt;&lt;img src="//images.ctfassets.net/8v4g74v8oew0/4E0Had9zB5iRAGQakCuJo5/baa15b2474df6ea9c8b873ca0940156f/image2.png" alt="image2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Properties that also create stacking contexts are (source from &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context#The_stacking_context"&gt;MDN&lt;/a&gt;): &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Element that is a child of a flex (flexbox) container, with z-index value other than auto.&lt;/li&gt;
&lt;li&gt;Element that is a child of a grid (grid) container, with z-index value other than auto.&lt;/li&gt;
&lt;li&gt;Element with an opacity value less than 1.&lt;/li&gt;
&lt;li&gt;Element with a mix-blend-mode value other than normal.&lt;/li&gt;
&lt;li&gt;Element with any of the following properties with a value other than none:&lt;/li&gt;
&lt;li&gt;transform&lt;/li&gt;
&lt;li&gt;filter&lt;/li&gt;
&lt;li&gt;perspective&lt;/li&gt;
&lt;li&gt;clip-path&lt;/li&gt;
&lt;li&gt;mask / mask-image / mask-border&lt;/li&gt;
&lt;li&gt;Element with an isolation value isolate.&lt;/li&gt;
&lt;li&gt;Element with a -webkit-overflow-scrolling value touch.&lt;/li&gt;
&lt;li&gt;Element with a will-change value specifying any property that would create a stacking context on non-initial value.&lt;/li&gt;
&lt;li&gt;Element with a contain value of layout, or paint, or a composite value that includes either of them (i.e. contain: strict, contain: content).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Why these properties have side-effects like these, is unclear. &lt;/p&gt;

&lt;h3&gt;
  
  
  Solving it in when using React
&lt;/h3&gt;

&lt;p&gt;Most React applications can consist of those more complex DOM hierarchies, which won’t allow you to swap out elements with their own stacking context so easily. However, React incorporated a neat addition called “Portals” in v16. Portals will allow you to mount any DOM element at any place in your DOM structure. React also mentions this in their documentation: &lt;/p&gt;

&lt;p&gt;&lt;em&gt;“A typical use case for portals is when a parent component has an overflow: hidden or z-index style, but you need the child to visually “break out” of its container. For example, dialogs, hovercards, and tooltips.“&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Summary
&lt;/h3&gt;

&lt;p&gt;I hope this helped you prevent future headaches by learning about stacking contexts and the way they interact with z-indexes. Here is a summary of this post: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Applying certain CSS properties will allow you to control the stacking context.&lt;/li&gt;
&lt;li&gt;Applying a z-index value of the highest possible value number to a local stacking context won’t make that element appear above other elements with stacking contexts living higher up in the DOM.&lt;/li&gt;
&lt;li&gt;Z-indexes only have meaning in their self-contained stacking context (global or local)&lt;/li&gt;
&lt;li&gt;Layouts can have many stacking contexts alongside each other, and inside each other. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thanks for reading and good luck stacking! &lt;/p&gt;

</description>
      <category>css</category>
      <category>stackingcontext</category>
      <category>frontend</category>
      <category>html</category>
    </item>
  </channel>
</rss>
