<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Nils Binder on Medium]]></title>
        <description><![CDATA[Stories by Nils Binder on Medium]]></description>
        <link>https://medium.com/@nilsbinder?source=rss-c36ac8107894------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*_5I7S3AoYGLzfHa4ehbbZw.jpeg</url>
            <title>Stories by Nils Binder on Medium</title>
            <link>https://medium.com/@nilsbinder?source=rss-c36ac8107894------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 01:56:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nilsbinder/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Sizing Blocks or Areas using CSS Custom-Properties]]></title>
            <link>https://medium.com/@nilsbinder/sizing-blocks-or-areas-using-css-custom-properties-a44979f69ff4?source=rss-c36ac8107894------2</link>
            <guid isPermaLink="false">https://medium.com/p/a44979f69ff4</guid>
            <category><![CDATA[css]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[web-design]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[custom-properties]]></category>
            <dc:creator><![CDATA[Nils Binder]]></dc:creator>
            <pubDate>Mon, 17 Jun 2019 00:00:00 GMT</pubDate>
            <atom:updated>2019-06-18T11:51:01.237Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TeNHRPeZ9cFCoJJ_quMJQg.png" /></figure><p>One of the many challenges when it comes to writing CSS is choosing the right unit. Over the years there has been a lot of controversy whether to use px, em or rem to size text. So I thought, why not add some custom properties to this mixture and see where it leads us. To not overcomplicate things and quickly get to the point, I will first describe my current approach when it comes to handling font-sizes. In part two, I will sprinkle in some custom properties.</p><h3>Part I: My Current Approach (without custom properties)</h3><p><strong>TL/DR:</strong> Percentages at the Root, rem for Components, em for everything else (yes everything!).</p><p>My current approach is very similar to the ones described by <a href="https://css-tricks.com/rem-global-em-local/">Robin Rendle</a>, <a href="https://css-tricks.com/rems-ems/">Chris Coyer</a>, and <a href="http://clagnut.com/blog/2384/">Richard Rutter</a>. I strongly prefer relative units over pixels. So in my CSS-Files, you will find something like this mostly all of the time:</p><p><strong>A little reminder:</strong> 1em is relative to the font size of the element. 1rem refers to the root font size (HTML) which is mostly set to 16px as a default. In fact, I’d love to hear if there is a browser these days that does not use 16px as the default font-size.</p><p>I have to admit, I try to define nearly everything with em, whether it is font-size, margin, padding, width, height or even things like box-shadow. The main reason is, I don&#39;t want to end up with something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*K0hnxIoiIB4CCYM4.jpeg" /></figure><p>I know, working solely with em can get a little messy, as everything is calculated using the font-size of its parent element as its basis. And once you are like three levels deep, you tend not to know what precisely that basis is.</p><h3>Reset at the top</h3><p>To make things a little easier I do a reset, whenever I start building a new block. (If you are more of a React developer, simply think of components instead of blocks, or maybe module is the right word for you? 😀) I set the font size to 1rem so it uses the root font-size as its basis and ignores whatever font-size was set on the parent. From there I go on using em. My CSS (in fact its SCSS, that&#39;s what I&#39;m used to writing) looks something like this:</p><p>I know working with em and rem instead of px is still a little uncomfortable for some people. To make it easier, you can rely on calc and write something like: font-size: calc(32em / 16), or you can use one of the many SASS mixins to make the calculations for you.</p><h3>Why should I do that?</h3><p>Getting rid of all your pixel-declarations has significant advantages:</p><ol><li><strong>Modify the size of your component</strong><br> You can resize your component by adding a modifier that changes the font size on the block level ( e.g., font-size: 0.875rem ). In the Codepen below there are two modifier-classes applied ( teaser--small &amp; teaser--tiny) that change the font-size and you can see that the whole teaser scales down.</li><li><strong>Resize the whole website</strong><br> But you don’t have to stop here. What I like most about all this and also used in nearly all of the projects I’ve been working on lately, is that you can scale your whole website by merely changing the font-size of the HTML element. Let’s say you want to optimize your website for large screens. Just add a media query, blow up your font size to 125% and watch your website scale up. Wooooooow.</li></ol><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2Fenbee81%2Fembed%2Fpreview%2FdazEWr%3Fheight%3D600%26slug-hash%3DdazEWr%26default-tabs%3Dhtml%2Cresult%26host%3Dhttps%3A%2F%2Fcodepen.io&amp;url=https%3A%2F%2Fcodepen.io%2Fenbee81%2Ffull%2FdazEWr&amp;image=https%3A%2F%2Fscreenshot.codepen.io%2F963316.dazEWr.small.e2485169-e7b0-4357-ad45-ee67f4d17087.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/ef60cd17e5fddf2ca4abef310a589de6/href">https://medium.com/media/ef60cd17e5fddf2ca4abef310a589de6/href</a></iframe><p>If you want to see this in action, have a look at one of these Websites and resize your browser to something wider than 1440px.</p><ul><li><a href="https://tev.de/">TEV - More than an investor. Your partner.</a></li><li><a href="https://ruhrjs.de/">RuhrJS Conference 2019</a></li></ul><h3>Challenges with nested Blocks</h3><p>Because there is a reset at the beginning of every block, things get a little complicated, when you have nested blocks. You can apply a modifier (e.g., font-size: 1.25rem) to a parent block, but the font-size is reduced to 1rem within the nested block, so it appears smaller in relation to the parent. If you want to change the child-blocks as well, you&#39;d have to apply modifiers to every child 😞. As a solution to this problem, you can use a custom property instead of solely relying on rem. Let&#39;s see how this works.</p><h3>Part II: Add a Custom Property</h3><p>Instead of doing a reset by setting font-size to 1rem, you can also use a custom property. Our CSS will change to this:</p><p>Not much has changed so far. The custom property --fs is used as a variable (like a variable known from preprocessors like Sass), and its value is placed as a reset-value for font-size on the block level. It gets really interesting, once you change the value of the custom property. Let&#39;s say we use a modifier class and increase the font-size:</p><p>Because the variable’s value cascades down, also nested blocks are affected by it, and the whole component including its sub-components scale up evenly.</p><p>It is also possible, to change the size of whole areas (e.g. Content, Footer, Sidebar) at different viewport sizes. Maybe for a blog layout where you want a bigger content to achieve better readability, but want your header and footer to stay as they were. And still, you have the possibility to change the root font-size and the whole page will scale up or down but maintain the ratio between different areas.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QSsmMo4CSYDmhO5v.png" /></figure><h3>Have fun trying it out.</h3><p>I created a <a href="https://codepen.io/enbee81/full/GeBVam"><strong>Codepen</strong></a> where you can play around with the root font-size and also resize two areas (content and sidebar) by adjusting a custom property.</p><h3>Final words</h3><p>With the rise of new CSS Layouting methods like Flexbox and CSS-Grid, we finally have the tools to create art directed layouts, that don’t have to look like the standard bootstrap layouts we saw quite a lot over the last years. Still, it is a huge challenge to build appealing layouts for all the different screen sizes. I hope the ability to dynamically resize individual areas can be another building block in creating innovative and exciting web experiences.</p><h4>Further Reading on Custom Properties</h4><p>Mike Riethmuller: <a href="https://www.smashingmagazine.com/2017/04/start-using-css-custom-properties/">It’s Time To Start Using CSS Custom Properties</a><br> Serg Hospodarets: <a href="https://www.smashingmagazine.com/2018/05/css-custom-properties-strategy-guide/">A Strategy Guide To CSS Custom Properties</a><br> Robin Rendle: <a href="https://css-tricks.com/using-custom-properties-modify-components/">Using Custom Properties to Modify Components</a></p><h4>Further Readion on relative Sizing</h4><p>Andy Bell: <a href="https://andy-bell.design/wrote/relative-sizing-with-em-units/">Relative sizing with EM units</a><br> Robin Rendle: <a href="https://css-tricks.com/rem-global-em-local/">Use rem for Global Sizing; Use em for Local Sizing</a><br> Richard Rutter: <a href="http://clagnut.com/blog/2384/">Use rems for global sizing, use ems for local sizing</a></p><p><em>Originally published at </em><a href="https://9elements.com/io/sizing-blocks-or-areas-using-css-custom-properties/"><em>https://9elements.com</em></a><em> on June 17, 2019.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a44979f69ff4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CSS Border-Radius Can Do That?]]></title>
            <link>https://medium.com/@nilsbinder/css-border-radius-can-do-that-d46df1d013ae?source=rss-c36ac8107894------2</link>
            <guid isPermaLink="false">https://medium.com/p/d46df1d013ae</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[web-design]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[front-end-development]]></category>
            <dc:creator><![CDATA[Nils Binder]]></dc:creator>
            <pubDate>Tue, 09 Oct 2018 00:00:00 GMT</pubDate>
            <atom:updated>2018-10-11T11:51:02.215Z</atom:updated>
            <content:encoded><![CDATA[<h4>How to create very cool effects with a rarely used feature.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YHfDXXFSy8liRyr55TSQrw.png" /></figure><p><strong>TL/DR:</strong> When you use eight values specifying border-radius in CSS, you can create organic looking shapes. WOW. No time to read it all ? — we made a visual tool for you. <a href="https://9elements.github.io/fancy-border-radius/">Find it here</a>.</p><h3>Introduction</h3><p>During this year’s <a href="https://frontendconf.ch/">Frontend Conference Zurich</a> <a href="https://medium.com/u/be9c04b39015">Rachel Andrew</a> talked about <a href="https://vimeo.com/287981360"><strong>Unlocking the Power of CSS Grid Layout</strong></a>. At the end of her talk, she mentioned something about an old CSS property that got stuck in my head:</p><blockquote>“The Image is set round just by using the well-supported border-radius. Don’t forget that old CSS still exists and is useful. You don’t need to use something fancy for every effect.” — Rachel Andrew</blockquote><p>Shortly after I heard this talk, I thought that you certainly could create more than just circles and started to dig deeper into what can be done using border-radius.</p><h3>Mastering border-radius</h3><h4>Single value</h4><p>Let’s start with the basics. Hope this will not bore you. You are probably familiar with CSS, and you also know border-radius. It is around for some years now, mostly used with a single value like this: border-radius: 1em and was maybe one of the most discussed/loved CSS3 features back in 2010 when <a href="http://css3please.com/">css3please.com</a> was your best friend.</p><p>Whenever you only use a single value, all corners are rounded by this value:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/859/1*74zA5u1RyOe1ugP1UhZFEw.png" /></figure><p>As you can see in the example above, next to fixed length values like px, rem or em you can also use percentages. Those are mostly used to create a circle by setting border-radius to 50%. The percentage value is based on the width and height of the given element. So when you use it on a rectangle, you will no longer have symmetrical corners. Here’s an example showing the difference between border-radius: 110px and border-radius: 30% applied to a rectangle.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*dwqmuSMqnEFmeUYXQ4l3OQ.png" /><figcaption>Notice that the corners on the right side are not symmetrical and keep that in mind. We’ll come back to this later.</figcaption></figure><h4>Four different values</h4><p>When you use more than one value, you start setting values for each corner, beginning in the top left corner and then moving clockwise. Again you can also use percentages, and you could also mix percentages with fixed-length values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/859/1*IaRgmKYRetA5uKD6KLoFmw.png" /></figure><h4>Eight values separated by a slash (this is where it gets interesting)</h4><p>I think most of you have already done everything I explained above. Now we get to the exciting part. What happens, if you separate values with a slash and specify up to eight values? Let’s see, what the spec says about that:</p><blockquote>“If values are given before and after the slash, then the values before the slash set the horizontal radius and the values after the slash set the vertical radius. If there is no slash, then the values set both radii equally.” <a href="https://www.w3.org/TR/css-backgrounds-3/#border-radius">W3C</a></blockquote><p>So, values before the slash are responsible for horizontal distances whereas values after the slash define the vertical lengths. But what does that mean? Remember percentage values on rectangular shapes? We had different absolute values for vertical and horizontal distances and asymmetrically rounded corners, and that is precisely what you get when you use the <em>slash syntax</em>.</p><p>So when you compare border-radius: 4em 8em to border-radius: 4em / 8em the results are quite different.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*QCmekXWZM-6q3TnHr2RfPw@2x.png" /><figcaption>The symmetrical corners on the left form quarter of a circle, whereas the asymmetrical corners on the right are part of an ellipsis.</figcaption></figure><p>The shapes that you get with this look a little odd, to be honest. But remember the circles you create with border-radius: 50%. You get a circle because both values defining one side add up to 100% (50% + 50% = 100%) and there is no straight line left, that reminds you of the original square. If you apply the same logic to the full eight value border-radius syntax, you can create a shape that looks a little like a plectrum or an organic cell:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/859/1*cCf-sH51ViWf6X7b4iAIgQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*kz683g1GSfzfKxW9enAVDw.png" /><figcaption>In the end it is four overlapping ellipses that build the final shape. Easy ha!</figcaption></figure><h4>Don’t panic… we made a visual generator for you</h4><p>It took me some time to get used to this syntax. Somehow it is not that intuitive. To make things a little easier for you, we built a little tool, that helps you create your very own organic shape.</p><figure><a href="https://9elements.github.io/fancy-border-radius/"><img alt="" src="https://cdn-images-1.medium.com/max/300/1*FmGc2je0u2fEqeEH_wPXNA.png" /></a></figure><h3>Do(n’t) Cross The Streams</h3><p>Now that you know about the 8 values in total, you might feel a little sad, because our border-radius-tool doesn’t give you the option to set each value separately…Sit tight, here is the <a href="https://9elements.github.io/fancy-border-radius/full-control.html#10.10.10.10-90.90.90.90-."><strong>8-POINT-FULL-CONTROL</strong></a> version.</p><p>If you’re old enough, you might remember this <a href="https://www.youtube.com/watch?v=jyaLZHiJJnE">quote</a> from the 1984s <a href="https://www.imdb.com/title/tt0087332/?ref_=nv_sr_2">Ghostbusters</a> movie:</p><blockquote><em>“Don’t Cross The Streams.” — “Why?” — “It would be bad.”</em></blockquote><p>There is something similar going on here: If you cross the handles on one side, the shape behaves…let’s say unpredictably. But <a href="https://9elements.github.io/fancy-border-radius/full-control.html#65.57.51.47-73.49.58.52-.">see for yourself</a>, after all, it’s not going to end up in total protonic reversal or something, but don’t say, that I didn’t warn you.</p><p><strong>PS.</strong>: Many Thanks to <a href="https://medium.com/@simurai">simurai</a>. Back in 2010, he created some <a href="http://simurai.com/archive/buttons/">CSS3 BonBon Buttons</a>. Even though they look a little outdated, it is the only place I ever encountered and learned about the slash syntax.</p><h3>See this cool feature in action.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zS6oNKtcPal6tvYVYYgqzA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4tGCblN6m875er1R1yjFcA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0nW-gEQWZtHRptFxDA2Gmw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*541uWCKy1IOAhrhv4lFp1A.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qAt6mf5t9rUzvd4e5_mhFg.jpeg" /><figcaption>Photos by <a href="https://gratisography.com/">gratisography.com</a></figcaption></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2Fenbee81%2Fembed%2Fpreview%2FLBMKqV%3Fheight%3D600%26slug-hash%3DLBMKqV%26default-tabs%3Dcss%2Cresult%26host%3Dhttps%3A%2F%2Fcodepen.io&amp;url=https%3A%2F%2Fcodepen.io%2Fenbee81%2Fpen%2FLBMKqV&amp;image=https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fi.cdpn.io%2F963316.LBMKqV.small.a72353dc-1bca-4b68-8a32-06a9dd2906cb.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/2e1445b0e2c4258307474038eb52ebe0/href">https://medium.com/media/2e1445b0e2c4258307474038eb52ebe0/href</a></iframe><p><em>Originally published at </em><a href="https://9elements.com/io/css-border-radius/"><em>9elements.com</em></a><em> on October 9, 2018.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d46df1d013ae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating an animated SVG Neon light effect]]></title>
            <link>https://medium.com/@nilsbinder/creating-an-animated-svg-neon-light-effect-f5d1487d9d39?source=rss-c36ac8107894------2</link>
            <guid isPermaLink="false">https://medium.com/p/f5d1487d9d39</guid>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[sketch]]></category>
            <category><![CDATA[animation]]></category>
            <category><![CDATA[svg]]></category>
            <dc:creator><![CDATA[Nils Binder]]></dc:creator>
            <pubDate>Wed, 25 Jul 2018 00:00:00 GMT</pubDate>
            <atom:updated>2018-08-07T14:18:00.172Z</atom:updated>
            <content:encoded><![CDATA[<h4>Full Tutorial — From Illustrator to Sketch to SVG</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sw5uuE1f4NnMSRgC.gif" /><figcaption>Look <a href="https://ruhrjs.de/tickets">here</a>, to see the animation in action. And yeahh this one right here is a GIF… 1.5MB, I know, not a good solution :-)</figcaption></figure><p>We at <a href="https://9elements.com/">9elements</a> organize an annual JavaScript conference called <a href="https://www.ruhrjs.de/">RuhrJS</a>. The key visual shows a shaft tower and the conference name executed with a neon light effect. The main page features the full visual with flickering lights. This effect is created by using a video loop in the background. Our visual designer (<a href="http://www.tommi-gutscher.de/">Tommi Gutscher</a>) also created some lovely images for all the sections on the website. So when the website was built, our frontend developer asked me to export some transparent .png files for her, so she can insert them in the header region.</p><p>I took a look at the files and saw that a lot of blur and shadow effects were used to create the neon light effect. To export a transparent file my first attempt was the good old:<br> <strong>cmd+shift+c</strong> copy merged<br> <strong>cmd+n</strong> create new file<br> <strong>cmd+v</strong> paste from clipboard<br> <strong>cmd+option+shift+s</strong> export for web<br> (pretty old school I know).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/526/0*tbXWFE9coAnTuTru.png" /><figcaption>When exported as transparent png, filesize is about 80KB</figcaption></figure><p>The resulting image was about 80KB large and not crisp on my high-resolution MacBook. Also, 80KB are a hell lot of bytes, especially when you’re at the conference and want to look up the schedule on a poor data plan. Somehow while doing all this, I had a strange feeling. It all felt like being thrown back about ten years.</p><h3>Switching to SVG</h3><p>A little frustrated I had another look at the project folder and found an Illustrator file with some very nice and clean vector paths for all the various header images. This was when I thought that maybe SVG would yield a better result. And maybe it also wouldn’t have to be static.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*gRQKTOcCJ14ZwFKj.png" /><figcaption>The original Vector Illustrations done for the Header images.</figcaption></figure><p>I don’t want to keep you on tenterhooks. The final result is about 10KB in file size, crisp on every resolution and on top of that, it’s also animated. To me, this seems much better and up do date.</p><h4>Final Result</h4><p>If you want to see the results just visit some of the sub-pages:</p><ul><li><a href="https://ruhrjs.de/tickets">RuhrJS — Tickets</a></li><li><a href="https://ruhrjs.de/speakers">RuhrJS — Speakers</a></li><li><a href="https://ruhrjs.de/schedule">RuhrJS — Schedule &amp; Location</a></li><li><a href="https://ruhrjs.de/sponsors">RuhrJS — Sponsors</a></li></ul><h3>Step by step walktrough</h3><p>I will take you through every step of building an animated neon sign with glow filters for yourself. You should have some basic knowledge of SVG, CSS, and Sketch. The first part is done in Illustrator and Sketch, so if you’re more of a <strong>frontend developer</strong>, just grab my demo files and start with part two.</p><p>If you’re a <strong>graphic designer</strong> and afraid of code (psssst… don’t be), it may still be interesting for you to at least read part one, because you will learn some things, your developer is going to love you for.</p><figure><a href="http://static.9elements.com/medium/animated-neon-svg.zip"><img alt="" src="https://cdn-images-1.medium.com/max/416/1*uihIOLErSLgDk4OO4hYKmg@2x.png" /></a></figure><h3>Part one: Graphic Design</h3><h4>1.1 From Illustrator to Sketch</h4><p>I never really got comfortable with Illustrator, so my first step here will be to copy the paths from Illustrator to Sketch. So select the group you need and hit cmd + c, then switch to Sketch and press cmd + v. I don’t know when this started, but lately, when you copy from Illustrator to Sketch, it automatically creates a new Artboard. So what you see should look somewhat like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*PwOE-uepoj18qbN-z2N9Rg.png" /></figure><h4>1.2 Deleting unused clipping masks</h4><p>When you look at the layer panel, you see some groups with a layer named clip and another layer inside. The clip-rectangle has the exact same width and height as the layer above it and is set to Use as Mask. This happens quite often when you copy and paste paths from Illustrator to Sketch. Since both layers have the same dimensions, there is no actual masking happening so you can simply delete the clip elements and the groups. After that, your layer list will look a bit more clean:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*LDl6kvwXHtVrBQwS22Ufnw.png" /></figure><h4>1.3 Name and combine your layers</h4><p>When you export an Artboard as SVG, the layer names get converted to id names inside the SVG. Since we want to animate some paths, it is better to know which path represents which character(s). Right now all layers are named “Fill XX” which doesn’t help much. So let’s give all of them a name, that describes their content and also change the order.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/275/0*nX1BeOEZZ2kx4Qit.png" /></figure><p>Now it’s time to think about the final image and you have to decide which elements will be animated. I chose to only animate the capital letters and the Ampersand. The other elements don’t necessarily have to be a single layer and can be combined to one shape. Again, this makes it easier when we export the file as SVG. In this example, I combined <strong>o</strong>, <strong>cation</strong>, <strong>i-dot</strong>, and <strong>n</strong> so that I have a single layer that can be named <strong>ocation</strong>. My preferred way to do the combining is by simply dragging one layer onto another.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/272/0*yPuWLUOcmaGcK6AA.gif" /></figure><p>Finally, you have a very organized and neatly named layer list, that impatiently waits for some glow effects. Mine looks like this. I could have gone further and also combine <strong>chedule</strong> and <strong>ocation</strong> into a single layer, but I kept them for better readability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/275/0*y_rbI0jLJEUtvgg7.png" /></figure><h4><strong>1.4 Adding some glow</strong></h4><p>So far our image is a little flat. I added five shadows in total to get the desired glow effect. Three white shadows for the main glow, a black shadow to add a more depth and finally a turquoise one to cool everything down a little. After applying the shadows, we have to expand the Artboard so that everything is visible. Luckily there is the Resize to Fit option in Sketch, so the Artboard gets just the perfect size.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/0*kM1I-3PMP1Pg9-yM.png" /><figcaption>Here, you can see the settings I used for the glow effect</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*RhlhgJw-v6mGtLJo.png" /><figcaption>Resize the Artboard to make sure, that the whole shadow is visible. I used a dark background to better see the effect in place, but make sure you don’t export it.</figcaption></figure><p>Now everything is ready to be exported as SVG. Select the Artboard, hit <em>make exportable</em>, choose SVG and click on export.</p><p>Hip hip hurray…part one is done. Now it’s time to leave Sketch and open your preferred text-editor.</p><h3>Part Two: Frontend Development</h3><h4>2.1 Understanding the main SVG structure</h4><p>Now that we have our SVG, we have to optimize the exported code. The main structure looks like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/12111bd5a3fd8f9a98f13c9edb29a6b5/href">https://medium.com/media/12111bd5a3fd8f9a98f13c9edb29a6b5/href</a></iframe><p>So what is going on here? When you take a look at the &lt;defs&gt; area, you’ll see that there is a repeating pattern with a &lt;path&gt; and a &lt;filter&gt; element. Further down you’ll find another repeating pattern that contains a group (&lt;g&gt;) with two &lt;use&gt; Tags inside.</p><p>The elements inside the &lt;defs&gt; tag will not be rendered on the SVG-canvas. Paths and filters are defined in this section, so that they can be referenced from within the &lt;use&gt; tags.</p><p>In every &lt;g&gt; the same path is linked in both &lt;use&gt; tags (xlink:href=&quot;#path-1&quot;). The first one is responsible for the glow. It is filled black and gets a filter attribute that links to a &lt;filter&gt; already specified in the &lt;defs&gt; section (filter=&quot;url(#filter-2)&quot;). The second one is placed on top without any filter, but filled in white (fill=&quot;#FFFFFF&quot;). Without it, you’d only see the blur but not the actual form. Maybe this sounds a little confusing, but I think when you look at the simplified code above, you will understand what is going on.</p><h4>2.2 Getting comfortable with the filters</h4><p>Let’s take a closer look at one of the &lt;filter&gt; tags. Again, you can identify some elements that form some kind of repeating pattern:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/58e72baf1af783538b318740d294cc4c/href">https://medium.com/media/58e72baf1af783538b318740d294cc4c/href</a></iframe><p>Every shadow we applied in Sketch is built with three SVG filters that are combined. First there is the offset &lt;feOffset&gt;, then the result gets blurred &lt;feGaussianBlur&gt; and finally the blurred result is given a color via &lt;feColorMatrix&gt;. In the end, the four shadows are merged — this happens in the &lt;feMerge&gt; section. If you are not completely happy with the final glow effect, you can try editing the shadows directly inside the SVG instead of going back to Sketch. The stdDeviation attribute, for example, handles the blur amount while dx and dy are responsible for the x and y offset. You can also try to change the values inside the ColorMatrix, but this one is not really self-explanatory 😅.</p><h4>2.3 Optimizing your SVG</h4><p>Now that we understood how the SVG is structured, we can do some optimizations. The biggest one here is reducing the number of filters. Since we defined the same shadow for all paths in Sketch, one would assume, that you also only need one filter in the SVG. Sadly Sketch is not smart enough to do that, so we have to do it manually.</p><p>When you compare the defined filters, you’ll see, that they are 99% the same. So let’s try and see, what happens when we use the same filter on all &lt;use&gt; tags. Like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e6a9357e39c2041612b3487d2c6efb14/href">https://medium.com/media/e6a9357e39c2041612b3487d2c6efb14/href</a></iframe><p>The image still looks the same, with the same filter applied to all paths. And this is exactly what we want.</p><p>Now all the other filters that are not used anymore can be deleted. And the &lt;defs&gt; section will look nicely structured:</p><pre>&lt;defs&gt;<br>  <strong>&lt;filter ...&gt;</strong><br>  &lt;path ...&gt;<br>  &lt;path ...&gt;<br>  &lt;path ...&gt;<br>  &lt;path ...&gt;<br>  &lt;path ...&gt;<br>&lt;/defs&gt;</pre><p>One final word on filters: When you export filters from Sketch, the width, height, x and y attributes of the filter get some values that don’t really make sense to me. First of all, we can change the filterUnits value from <strong>objectBoundingBox</strong> to <strong>userSpaceOnUse</strong>. The filter coordinates are now calculated from the top left of the whole SVG and not from the object that uses the filter. Now we can set the width and height to 100% and the starting x and y attributes to zero.</p><pre>&lt;filter id=&quot;glow&quot; width=&quot;<strong>100%</strong>&quot; height=&quot;<strong>100%</strong>&quot; x=&quot;<strong>0</strong>&quot; y=&quot;<strong>0</strong>&quot; filterUnits=&quot;<strong>userSpaceOnUse</strong>&quot;&gt;</pre><p>In the end, I named the filter “glow” instead of “filter-2” to make it a bit more readable. You could also rename the paths, but having the IDs in the groups was enough for me. The only thing I did was correcting the numbers of the paths so that you have nice ascending numbers.</p><p>Of course, you can (and should) use something like <a href="https://jakearchibald.github.io/svgomg/">SVGOMG</a> to further reduce file size. But be careful and don’t use the Clean IDs option. This will rename all your IDs to single character names and then it will be very hard to read. With accessibility in mind I’d also recommend to leave the &lt;title&gt; in place and write something meaningful in there.</p><p>Here you can see the final code of the static SVG:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2ad28de42bf3c5a87974e58b329bf88b/href">https://medium.com/media/2ad28de42bf3c5a87974e58b329bf88b/href</a></iframe><h4>2.4 Adding animation</h4><p>We’ll use CSS to animate parts of the image. If you’re planning to insert the final image via &lt;img&gt; you have to write your CSS directly inside the SVG file. If you want to have the styles inside your general CSS file, you need to inline the SVG, because otherwise you don’t have access to its paths.</p><p>The keyframe animation is quite simple. All you have to do is switch the opacity from something like 0.4 to 1. We want to create the effect of an old neon sign, that flickers from time to time. To achieve this, simply insert a lot of steps from 0% to 10% and then a pause to 100%:</p><pre>@keyframes flicker {<br>  0%    { opacity: 1;   }<br>  3%    { opacity: 0.4; }<br>  6%    { opacity: 1;   }<br>  7%    { opacity: 0.4; }<br>  8%    { opacity: 1;   }<br>  9%    { opacity: 0.4; }<br>  10%   { opacity: 1;   }<br>  100%  { opacity: 1;   }<br>}</pre><p>Once this is defined, you can use it on every element you want to animate. Let’s say we want to use the defined flicker animation, and we want it to have a duration of 6 seconds. The whole animation should be played in an infinite loop and in order to mimic a flickering neon light, we don’t want to ease between the steps, but “jump” directly from one state to the next. Sounds complicated, but it is actually just one line of CSS:</p><pre>#L { <br>  animation: <strong>flicker 6s infinite step-end</strong>; <br>}</pre><p>For the &amp; I chose a duration of 5 seconds and added a delay of 2 seconds. With the two different duration timings, the whole animation looks a little more random and natural.</p><pre>#et { <br>  animation: flicker <strong>5s</strong> infinite <strong>2s</strong> step-end; <br>}</pre><p>Well and that’s it. Our animated neon sign SVG is ready. Here you can see the full code.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2Fenbee81%2Fembed%2Fpreview%2FQxJOad%3Fheight%3D600%26slug-hash%3DQxJOad%26default-tabs%3Dhtml%2Cresult%26host%3Dhttps%3A%2F%2Fcodepen.io%26embed-version%3D2&amp;url=https%3A%2F%2Fcodepen.io%2Fenbee81%2Ffull%2FQxJOad%2F&amp;image=https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fm.cdpn.io%2Fscreenshot-coming-soon-small.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/af768eb84e31d4aeed199588c7d5f23c/href">https://medium.com/media/af768eb84e31d4aeed199588c7d5f23c/href</a></iframe><blockquote>Over to you: I hope this tutorial has been useful and I’d certainly love to see some of your results.</blockquote><blockquote>If you’ve enjoyed this piece and would like to see more, you might want to check out our <a href="https://9elements.com/?utm_campaign=Tech&amp;utm_source=Medium&amp;utm_medium=Organic&amp;utm_content=Blog%20Post%20Responsive%20Image&amp;utm_term=Nils%20Binder">Website</a>, follow us on <a href="https://twitter.com/9elements">Twitter</a> or subscribe to our <a href="https://mailchi.mp/af3f70f18955/9elements-lets-stay-in-touch">Newsletter</a>.</blockquote><p><strong>Edit 07.Aug 2018</strong></p><p><a href="https://medium.com/u/a4291050cbf4">hoorahforsnakes</a> improved my pen by adding another keyframe animation and applying it to the glow component inside the letter groups. The opacity in this animation is set to 0 and not only to 0.4. Looks a little more realistic, because there is no glow visible during the flickering.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2Fenbee81%2Fembed%2Fpreview%2FqyJEPY%3Fheight%3D600%26slug-hash%3DqyJEPY%26default-tabs%3Dhtml%2Cresult%26host%3Dhttps%3A%2F%2Fcodepen.io%26embed-version%3D2&amp;url=https%3A%2F%2Fcodepen.io%2Fenbee81%2Fpen%2FqyJEPY&amp;image=https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fm.cdpn.io%2Fscreenshot-coming-soon-small.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/78065a791b0f3e48ebcb485b7f2c89bd/href">https://medium.com/media/78065a791b0f3e48ebcb485b7f2c89bd/href</a></iframe><p><em>Originally published at </em><a href="https://9elements.com/io/creating-an-animated-SVG-Neon-light-effect/"><em>9elements.com</em></a><em> on July 25, 2018.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5d1487d9d39" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a responsive image]]></title>
            <link>https://medium.com/@nilsbinder/building-a-responsive-image-e4c6229fa1f6?source=rss-c36ac8107894------2</link>
            <guid isPermaLink="false">https://medium.com/p/e4c6229fa1f6</guid>
            <category><![CDATA[logo-design]]></category>
            <category><![CDATA[responsive-design]]></category>
            <category><![CDATA[svg]]></category>
            <category><![CDATA[design]]></category>
            <category><![CDATA[css]]></category>
            <dc:creator><![CDATA[Nils Binder]]></dc:creator>
            <pubDate>Tue, 29 May 2018 08:01:03 GMT</pubDate>
            <atom:updated>2018-06-01T06:11:20.118Z</atom:updated>
            <content:encoded><![CDATA[<h4>How to create a logo that responds to its own aspect ratio</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rLoeBZk3z58by02A_J5Hsg.png" /></figure><p>There are quite a few articles on the web that deal with responsive logos. The most popular example might be the <a href="http://responsivelogos.co.uk/">Responsive Logos website</a> that shows some very well known logos in different variations for different screen sizes. When I first saw this example, I thought it wasn’t much more than a little gimmick. In the end, it is just &lt;div&gt; with a big image sprite as background. It wasn’t until I heard a talk at Smashing Conference by <a href="https://twitter.com/MikeRiethmuller">@MikeRiethmuller</a> titled: <a href="https://vimeo.com/235428198">Beyond Media Queries</a>, that I got more interested in this topic. In addition to the talk, I highly recommend reading his article “<a href="https://www.madebymike.com.au/writing/svg-has-more-potential/">SVG has more potential</a>”.</p><h4>There are two things I learned that really got me excited.</h4><ol><li>When using SVG, you can drop the viewBox attribute and establish a new coordinate system on nested SVG-symbol elements by applying a new viewBox. (Yeah I know. Sounds confusing. Below, I’ll explain in more detail.)</li><li>When you use media queries inside SVG files and then insert the image via img-tag or as a CSS background-image, the media queries are bound to the width of the image. Pretty much the same behavior as if you used <a href="https://alistapart.com/article/container-queries-once-more-unto-the-breach">Container Queries</a>.</li></ol><h3>The idea was born</h3><p>After I read about all this, I got the idea to build a logo file for our company, that not only reacts to the browser width but instead adapts while respecting its aspect ratio. So you can use it anywhere, and the file itself <em>chooses</em> which version to show depending on the size it’s given.</p><h4><strong>The final result</strong></h4><p>If you’re already excited, download the final <a href="https://www.ichimnetz.com/responsive-logo/9e-anywhere.svg"><strong>DEMO FILE</strong></a><strong> </strong>or see it in action in this <a href="https://codepen.io/enbee81/full/QrNRdm/">CodePen</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oVoEyolSMeLECM3zQWs4bg.gif" /></figure><h3>Step by step <strong>(…uuh Baby ♬ )</strong></h3><p>In the following, I’m going to walk you through every step you have to perform to build your own responsive Logo. You should at least have some basic knowledge about SVG and also CSS. But the good news is: there will be no JavaScript at all. For the most part, we just have to copy code from one file to another.</p><h4>1. Designing the logo</h4><p>Let’s start by designing four versions of our logo. My tool of choice for that is <a href="https://www.sketchapp.com/">Sketch</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bVWMOi6RPVVp6-8YRTIEtA.png" /><figcaption>Logo Variations: 1. Skyscraper — 2. Portrait — 3. Square — 4. Landscape</figcaption></figure><p>Whenever there are elements, that can be found on multiple versions, I recommend to use symbols in Sketch. This is going to make it easier for you in the future, and the SVG that we’re going to build is going to use the same symbols. (If you’re not familiar with symbols in Sketch I highly recommend this <a href="https://medium.com/ux-power-tools/this-is-without-a-doubt-the-coolest-sketch-technique-youll-see-all-day-ddefa65ea959">Medium Story</a> by <a href="https://medium.com/u/8cebe625c432">Jon Moore</a>.)</p><p>As you can see, the logo consists of a visual element and the company name. Only in the square version, I chose not to display the name. The reason for this is, that I wanted it to be recognizable, even when used as a tiny thumbnail by maybe only about 32px x 32px.</p><h4>2. Setting up the SVG file</h4><p>Before we export any images, we have to create a new SVG file. Maybe it’s a little frightening to start your SVG with writing code, but in the end, it is not too complicated. Pinky promise. All we need is an opening and a closing tag like this:</p><pre>&lt;svg width=”100%” height=”100%” xmlns=”<a href="http://www.w3.org/2000/svg">http://www.w3.org/2000/svg</a>&quot; xmlns:xlink=”<a href="http://www.w3.org/1999/xlink">http://www.w3.org/1999/xlink</a>&quot;&gt;</pre><pre>&lt;/svg&gt;</pre><p>If you look at the attributes, you’ll notice, that there is no viewBox attribute. We only set width and height to 100%.</p><p><em>(Note: There are also two xmlns attributes present. To be honest, I don’t exactly know why they have to be there, I should probably google it… anyway if you delete them, you will not be able to use any symbols within the SVG and get some ugly error messages instead.)</em></p><h4>3. Exporting SVG-symbols</h4><p>Because we will be using both elements as symbols in the final SVG, we have to put each of them on a single artboard and export them as SVG.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*gSdjNhOjAFtS2rB12HRAUw.gif" /><figcaption>Place all symbols on seperate artboards before you export them as SVG</figcaption></figure><p>It is crucial that you do not export the objects but always create a new artboard. If you export elements from a bigger artboard, you will end up with strange looking transform attributes attached to your groups. It also helps to detach all symbols and delete all unused groups. Finally, do some proper naming and see if there is any mask applied, that is not used.</p><p>Now let’s see, what the exported code looks like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8b445417ad4f1c329c537bd14c5c9775/href">https://medium.com/media/8b445417ad4f1c329c537bd14c5c9775/href</a></iframe><p>I’d recommend to use something like <a href="https://jakearchibald.github.io/svgomg">SVGOMG</a> to reduce file size and delete all the unnecessary stuff. But do <strong>not</strong> clean IDs. If you named your layers in Sketch you can identify them easier by ID in the final file. This is how your optimized file is going to look like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d3ee10220064d4de1d3760b1f5eba23b/href">https://medium.com/media/d3ee10220064d4de1d3760b1f5eba23b/href</a></iframe><p>If everything is correct, you will see a group that has the name of your artboard as ID. Inside of this group is the content, that is of interest. In this case it’s a rectangle serving as background and a complex path that builds the IX (roman 9 rotated counter-clockwise by 90 degrees … just in case you were asking).</p><h4>4. Building the symbols</h4><p>All our files are ready and can be put together. Start by writing some symbol tags in your final file and give each a unique ID as well as a viewBox attribute that matches the viewBox of the exported files.</p><pre>&lt;svg width=”100%” height=”100%” xmlns=”<a href="http://www.w3.org/2000/svg">http://www.w3.org/2000/svg</a>&quot; xmlns:xlink=”<a href="http://www.w3.org/1999/xlink">http://www.w3.org/1999/xlink</a>&quot;&gt;<br>  <strong>&lt;symbol id=”ix” viewBox=”0 0 160 160&quot;&gt;</strong><br>    &lt;!-- Insert Symbol Content here --&gt;<br>  <strong>&lt;/symbol&gt;</strong></pre><pre>  <strong>&lt;symbol id=”typography” viewBox=”0 0 144 16&quot;&gt;</strong><br>    &lt;!-- Insert Symbol Content here --&gt;<br>  <strong>&lt;/symbol&gt;</strong><br>&lt;/svg&gt;</pre><p>Finally, paste the content of your exported files (everything inside the group that is named like your artboard) inside the symbol tags. Once you’re done with that your file should look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/16b5daf4f11c94a3149cf6460383cc00/href">https://medium.com/media/16b5daf4f11c94a3149cf6460383cc00/href</a></iframe><h4>5. Using our symbols</h4><p>So far so good. Sadly, if you open the file in a browser, you won’t see anything. For now, we defined our symbols, but never placed them anywhere. To insert a symbol you need a use-tag in your file:</p><pre>&lt;use xlink:href=”#ix” x=”0&quot; y=”0&quot; width=”100&quot; height=”100”/&gt;</pre><p>Now let’s see what exactly is happening here.</p><p>First the xlink:href points to a symbol with a unique ID and will render its contents… well, it’s not really rendered, but cloned and suddenly there is a weird thing coming up called the <strong>Shadow DOM</strong>. It may sound like something from <em>Stranger Things</em>, but you don’t need to be afraid. As long as you don’t want to change anything inside the symbol instance via CSS, there is nothing to worry about.</p><p>Next we have the <strong>x</strong>, <strong>y</strong>, <strong>width</strong> and <strong>height</strong> attributes. You may already have guessed, that these attributes define the position and dimensions of the rendered symbol. But there is no unit given, so how big will our symbol be? Inside an SVG the units are defined by the viewBox attribute set in the SVG tag. Since we did not set a viewBox and only defined width and height (100%), one unit matches one pixel and our symbol will have a width of 100px. And it doesn’t matter if you change the width of the SVG. It will always stay at at 100px width.</p><p>Try changing the width and height attributes inside this <a href="https://codepen.io/enbee81/pen/BxKrdb">CodePen</a>. You will notice that the symbol will always keep its aspect ratio. Luckily this is exactly what we need for our logo. If you wanted to change the resizing behavior, you needed an attribute called preserveAspectRatio. Check out <a href="https://twitter.com/SaraSoueidan">@SaraSoueidan</a>’s Article on <a href="https://www.sarasoueidan.com/blog/svg-coordinate-systems/">Understanding SVG Coordinate Systems and Transformation</a> if you want to learn more about it.</p><p>Apart from the unitless values, you can also use percentages to define position and dimensions through the attributes. So to make this symbol look like the square version, simply use a width of 90% and position its upper left corner 5% from the bounding box of the image:</p><pre>&lt;use xlink:href=”#ix” x=”<strong>5%</strong>&quot; y=”<strong>5%</strong>&quot; width=”<strong>90%</strong>&quot; height=”<strong>90%</strong>”/&gt;</pre><p><em>(Maybe you think that setting width or height to ‘auto’ is a good idea… well, it’s not. Safari and Firefox simply ignore it while Chrome won’t render anything.)</em></p><h4>6. Combining symbols inside a new symbol</h4><p>For the portrait version, we’ll need both symbols. In order to make sure they scale proportional and always have the same distance to the border and to each other, we simply create yet another symbol. This symbol again has its own viewBox attribute which allows us to place our symbols within the new coordinate system. To see where exactly everything has to be placed, you can simply go back to your sketch file and inspect the sizes and distances.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/528/1*SLzMg-dfUGLtmuP_NOX8cw.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i7-rfeRLI8yOtQSlBteBAw.png" /><figcaption>Portrait-Version: Purple: viewBox — Red: Position — Turquoise: Width and Height</figcaption></figure><p>Now, we only have to translate all the numbers to our new SVG symbol, which will then look like this:</p><pre>&lt;symbol id=”portrait” viewBox=”0 0 <strong>160 180</strong>&quot;&gt;<br>  &lt;use xlink:href=”#ix” x=”<strong>40</strong>&quot; y=”<strong>32</strong>&quot; width=”<strong>80</strong>&quot; height=”<strong>80</strong>&quot;/&gt;<br>  &lt;use xlink:href=”#typo” x=”<strong>3</strong>&quot; y=”<strong>130</strong>&quot; width=”<strong>154</strong>&quot; height=”<strong>16</strong>&quot;/&gt;&lt;/symbol&gt;</pre><p>When we use this symbol, we wouldn’t want it at 100% width, so let’s just scale it down like our square symbol.</p><pre>&lt;use xlink:href=”#portrait” x=”5%&quot; y=”5%&quot; width=”90%&quot; height=”90%”/&gt;</pre><h4>7. Hide and show</h4><p>Up to this point we created three symbols and have two use tags in our SVG.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6d1c53fa9f02263c78067c6e296eb392/href">https://medium.com/media/6d1c53fa9f02263c78067c6e296eb392/href</a></iframe><p>Finally, the fun part begins, and we can make it responsive. Right now both symbols are rendered on top of each other. To hide the parts we don’t want to display, we need to add some classes to the use tags.</p><pre>&lt;use <strong>class=&quot;square&quot;</strong> xlink:href=”#ix” x=”5%” y=”5%” width=”90%” height=”90%”/&gt;<br>&lt;use <strong>class=&quot;portrait&quot;</strong> xlink:href=”#portrait” x=”5%” y=”5%” width=”90%” height=”90%”/&gt;</pre><p>Now, the only thing missing is some CSS to show only one logo version at a time. You can add a &lt;style&gt; tag to your SVG and use some media queries just like you would in a regular CSS file.</p><p>In CSS you most likely use something like @media (min-width: 768px) { ... }, but then you are only looking at the width of the image. We are interested in aspect ratio and not width, so our media queries will have to look like this: @media (<strong>min-aspect-ratio: 1/2</strong>) { ... }.</p><p>For our first two versions, let’s make the portrait-version the default and show the single-IX-version only when the image width is at least the same as the image height. In other words: at the point where the image changes from portrait mode to landscape, we will not show the typography anyomore, only the graphical logo.</p><pre>&lt;style&gt;</pre><pre>  .square { visibility: hidden; }<br>  .portrait { visibility: visible; }</pre><pre>  @media (min-aspect-ratio: 1/1) {<br>    .square { visibility: visible; }<br>    .portrait { visibility: hidden; }<br>  }</pre><pre>&lt;/style&gt;</pre><p>If you create another symbol for the landscape version, you would probably want to show it when the width of the image is at least two times it’s height. Let’s see how the style changes:</p><pre>&lt;style&gt;</pre><pre>  .square,<br>  <strong>.landscape</strong> { visibility: hidden; }<br>  .portrait { visibility: visible; }</pre><pre>  @media (min-aspect-ratio: 1/1) {<br>    .portrait,<br>    <strong>.landscape</strong> { visibility: hidden; }<br>    .square { visibility: visible; }<br>  }</pre><pre>  @media (<strong>min-aspect-ratio: 2/1</strong>) {<br>    .portrait,<br>    .square { visibility: hidden; }<br>    <strong>.landscape</strong> { visibility: visible; }<br>  }</pre><pre>&lt;/style&gt;</pre><p>And that’s it. We’re done building our own responsive svg logo. Here, you can see the full code with three versions going from portrait mode to landscape:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/142e6da244779f55d8d19c2a8d9d3d33/href">https://medium.com/media/142e6da244779f55d8d19c2a8d9d3d33/href</a></iframe><h4>8. A little bit of transformation</h4><p>OK, OK… I know the skyscraper-version is missing in the example above. The reason here is, that you need to perform some transformation to create the needed symbol. I will not explain it in detail, but you can find the code you’ll need below:</p><pre>&lt;symbol id=”skyscraper” viewBox=”0 0 64 328&quot;&gt;</pre><pre>  &lt;use xlink:href=”#ix” x=”0&quot; y=”264&quot; width=”64&quot; height=”64&quot;/&gt;<br>  &lt;use xlink:href=”#typography” x=”-90&quot; y=”109&quot; width=”246&quot; height=”27&quot; <strong>transform=”rotate(-90 32 123)”</strong>/&gt;</pre><pre>&lt;/symbol&gt;</pre><blockquote>Over to you: I hope this tutorial has been useful and I’d certainly love to see some of your results.</blockquote><blockquote>If you’ve enjoyed this piece and would like to see more, you might want to check out our <a href="https://9elements.com/?utm_campaign=Tech&amp;utm_source=Medium&amp;utm_medium=Organic&amp;utm_content=Blog%20Post%20Responsive%20Image&amp;utm_term=Nils%20Binder">Website</a>, follow us on <a href="https://twitter.com/9elements">Twitter</a> or subscribe to our <a href="https://mailchi.mp/af3f70f18955/9elements-lets-stay-in-touch">Newsletter</a>.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e4c6229fa1f6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>