<?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: Marius Eisenbraun</title>
    <description>The latest articles on Forem by Marius Eisenbraun (@mr_eis).</description>
    <link>https://forem.com/mr_eis</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%2F308396%2Fdf467db0-9141-4e96-958b-569b87e73e98.jpg</url>
      <title>Forem: Marius Eisenbraun</title>
      <link>https://forem.com/mr_eis</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/mr_eis"/>
    <language>en</language>
    <item>
      <title>TIL: In CSS, DarkGray is lighter than Gray</title>
      <dc:creator>Marius Eisenbraun</dc:creator>
      <pubDate>Thu, 09 Jan 2020 21:47:54 +0000</pubDate>
      <link>https://forem.com/mr_eis/til-in-css-darkgray-is-lighter-than-gray-3j3l</link>
      <guid>https://forem.com/mr_eis/til-in-css-darkgray-is-lighter-than-gray-3j3l</guid>
      <description>&lt;p&gt;&lt;em&gt;When building prototypes or examples, I often use named CSS colors.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;After playing around and working with CSS for some years, today I learnt:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DarkGray is lighter than Gray 🤔&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It got me so confused, I had to check it three times.&lt;/p&gt;

&lt;p&gt;The easy solution:&lt;br&gt;
If you want a "dark gray", choose &lt;code&gt;DimGray&lt;/code&gt;.☝️&lt;/p&gt;

</description>
      <category>todayilearned</category>
      <category>css</category>
      <category>webdev</category>
    </item>
    <item>
      <title>What would you like to know about CSS?</title>
      <dc:creator>Marius Eisenbraun</dc:creator>
      <pubDate>Thu, 09 Jan 2020 21:32:19 +0000</pubDate>
      <link>https://forem.com/mr_eis/what-would-you-like-to-know-about-css-3n31</link>
      <guid>https://forem.com/mr_eis/what-would-you-like-to-know-about-css-3n31</guid>
      <description>&lt;p&gt;Hey, my front-end-friends!&lt;/p&gt;

&lt;p&gt;There are many css tutorials and code-snippets out there, but maybe &lt;em&gt;you&lt;/em&gt; got a topic that is not covered or just didn't find the right solution?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tell me in the comments, what you would like to know about CSS.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Hopefully I later can explain it in a short posting or other nice web-devs will give you some hints/links/examples.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let's share our knowledge! 🙌&lt;/strong&gt; &lt;/p&gt;

</description>
      <category>question</category>
      <category>css</category>
      <category>webdev</category>
      <category>learning</category>
    </item>
    <item>
      <title>simple responsive grid layout w/ css-grid</title>
      <dc:creator>Marius Eisenbraun</dc:creator>
      <pubDate>Sun, 05 Jan 2020 19:47:39 +0000</pubDate>
      <link>https://forem.com/mr_eis/simple-grid-layout-for-anything-e0f</link>
      <guid>https://forem.com/mr_eis/simple-grid-layout-for-anything-e0f</guid>
      <description>&lt;h2&gt;
  
  
  Why a grid?
&lt;/h2&gt;

&lt;p&gt;There are many reasons out there to display content as a well structured grid. Someone needs a small image gallery, the other one needs to display products or maybe a simple portfolio. And over all there is this trend to put content in &lt;em&gt;'cards'&lt;/em&gt; to structure the UI.&lt;/p&gt;

&lt;p&gt;Especially when you are in a component-based environment, it is very handy and powerful, to put the layout in the container-element so the child-components will just use it without any worries.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wouldn't it be nice, to have an easy solution with CSS, to start with?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here is one, using the implicit grid:&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The HTML
&lt;/h2&gt;

&lt;p&gt;We wanna keep it simple, with a container and some cards/items/elements inside of it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;main&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"card"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;1&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"card"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;2&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"card"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;3&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"card"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;4&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"card"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;5&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"card"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;6&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"card"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;7&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"card"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;8&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"card"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;9&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"card"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;10&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"card"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;11&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/main&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;&amp;lt;main&amp;gt;&lt;/code&gt; is our container. Every direct child should be displayed in a nice grid.&lt;/p&gt;

&lt;p&gt;'nice' in this context means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;elements get the same width&lt;/li&gt;
&lt;li&gt;the same hight&lt;/li&gt;
&lt;li&gt;on every screen size&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;So yes, of course it has to be responsive!&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The CSS
&lt;/h2&gt;

&lt;p&gt;So let's define our container via &lt;code&gt;display: grid&lt;/code&gt; and add some &lt;em&gt;'CSS-magic'&lt;/em&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;main&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;grid-template-columns&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;repeat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;auto-fit&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;minmax&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;300px&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
  &lt;span class="py"&gt;grid-auto-rows&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;minmax&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;150px&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;These three lines are all you need to define a simple and responsive grid.&lt;/p&gt;

&lt;p&gt;So, what happens:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. we define &lt;code&gt;&amp;lt;main&amp;gt;&lt;/code&gt; to be displayed as grid.
&lt;/h3&gt;

&lt;p&gt;Easy.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. we define columns
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;repeat&lt;/code&gt; generates a column or a pattern of columns in a given amount.

&lt;ul&gt;
&lt;li&gt;The amount of columns is the first value. The size or pattern is the second value. &lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;auto-fit&lt;/code&gt; is used, coz we don't know a fix number of columns. We just want as much columns as are fitting on the screen. So we let the browser generate this number for us.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;minmax(300px, 1fr)&lt;/code&gt; defines the size of each column. The size is fluid between the first and second value. So we set 300px as minimal size for each grid-item and with 1fr we make sure, the items always keep the same size.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;More about this pattern: &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/repeat"&gt;https://developer.mozilla.org/en-US/docs/Web/CSS/repeat&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  3. we define rows
&lt;/h3&gt;

&lt;p&gt;This &lt;code&gt;minmax()&lt;/code&gt; function is used to set a minimal height for each grid-item, but also to define that all items will have the same height.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;You could remove this line, if you don't want this even-height behavior and the rest of the responsive grid will work as expected.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Beautify
&lt;/h3&gt;

&lt;p&gt;Of course a grid-ui has some gaps between it's children, so let's add this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;main&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;grid-template-columns&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;repeat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;auto-fit&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;minmax&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;300px&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
  &lt;span class="py"&gt;grid-auto-rows&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;minmax&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;150px&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="py"&gt;grid-gap&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Also, sometimes a grid-item can be more important than others, so you change it's size (e.g. &lt;code&gt;grid-column: span 2;&lt;/code&gt;). In this cases you can generate empty spots in your well structured grid. To avoid this we add another line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;main&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;grid-template-columns&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;repeat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;auto-fit&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;minmax&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;300px&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
  &lt;span class="py"&gt;grid-auto-rows&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;minmax&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;150px&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="py"&gt;grid-gap&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;grid-auto-flow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;dense&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;(open it in new window to better see the responsive behavior)&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/mreis/embed/abzEdgm?height=600&amp;amp;default-tab=css,result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>css</category>
      <category>layout</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Centering in modern CSS</title>
      <dc:creator>Marius Eisenbraun</dc:creator>
      <pubDate>Sat, 04 Jan 2020 18:33:17 +0000</pubDate>
      <link>https://forem.com/mr_eis/centering-in-modern-css-3nme</link>
      <guid>https://forem.com/mr_eis/centering-in-modern-css-3nme</guid>
      <description>&lt;p&gt;Centering stuff in a layout sounds like a usual thing. Everyone does it in designs, sketches or even Word documents.&lt;/p&gt;

&lt;p&gt;But for the web it was complicated for years to centering content or HTML elements - especially in vertical direction.&lt;/p&gt;

&lt;h2&gt;
  
  
  The good ol' time
&lt;/h2&gt;

&lt;p&gt;You could use things like &lt;code&gt;display: table&lt;/code&gt; or later positioning + &lt;code&gt;transform: translate()&lt;/code&gt;. It works! But explaining that behavior to new developers was always a bit uncomfortable. Because the newbie and the teacher both got that feeling:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"There must be a better solution!"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Well, it is!&lt;/p&gt;

&lt;h2&gt;
  
  
  modern CSS
&lt;/h2&gt;

&lt;p&gt;In the CSS-era of &lt;code&gt;flexbox&lt;/code&gt; and &lt;code&gt;grid&lt;/code&gt; both display types offer an easy solution to this one big question:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.container-element&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="err"&gt;//&lt;/span&gt; &lt;span class="err"&gt;or&lt;/span&gt; &lt;span class="err"&gt;flex!&lt;/span&gt;
  &lt;span class="nl"&gt;align-items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;justify-content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;What ever element will but put inside that container, it will be centered. In both directions! &lt;/p&gt;

&lt;p&gt;In addition there are two more benefits:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;No fix values, means: &lt;strong&gt;responsive by default&lt;/strong&gt;!&lt;/li&gt;
&lt;li&gt;Not only centering child elements but also &lt;strong&gt;centering the pure text content&lt;/strong&gt; of the container&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  a short demo using both:
&lt;/h3&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/mreis/embed/WNbXPeB?height=600&amp;amp;default-tab=css,result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Codepen: &lt;a href="https://codepen.io/mreis/pen/WNbXPeB"&gt;https://codepen.io/mreis/pen/WNbXPeB&lt;/a&gt;&lt;/p&gt;

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