<?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: Ciaran Concannon</title>
    <description>The latest articles on Forem by Ciaran Concannon (@cjcon90).</description>
    <link>https://forem.com/cjcon90</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%2F396225%2F0ec7ac75-7368-464b-8ff1-e325a7b649f5.jpg</url>
      <title>Forem: Ciaran Concannon</title>
      <link>https://forem.com/cjcon90</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/cjcon90"/>
    <language>en</language>
    <item>
      <title>Quick tips to easily create a beautiful custom PDF resume with HTML and CSS</title>
      <dc:creator>Ciaran Concannon</dc:creator>
      <pubDate>Wed, 10 Feb 2021 23:07:28 +0000</pubDate>
      <link>https://forem.com/cjcon90/quick-tip-to-easily-create-a-totally-custom-pdf-resume-with-html-and-css-5bfo</link>
      <guid>https://forem.com/cjcon90/quick-tip-to-easily-create-a-totally-custom-pdf-resume-with-html-and-css-5bfo</guid>
      <description>&lt;p&gt;Nobody enjoys sitting down and writing their resume, right? But we &lt;em&gt;do&lt;/em&gt; enjoy making websites (hopefully most of the time anyway)&lt;/p&gt;

&lt;p&gt;So.... why is it normal practice to write our resumes in tools like Microsoft Word when we've got all these CSS skills just waiting to be used!&lt;/p&gt;

&lt;p&gt;Creating a full-page, full-bleed, totally custom PDF resume from a web-page is easy, it just depends on one piece of CSS code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="n"&gt;print&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nt"&gt;body&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;8.25in&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;11.75in&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&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;This will make it so that when you print a web page within Chrome, it will print it to perfectly fit the size of an A4 piece of paper.&lt;/p&gt;

&lt;p&gt;The only other setting you need to adjust at the print preview screen in Chrome; in 'More Settings' make sure Margin is set to None, print the page to PDF and there you have it! A custom HTML &amp;amp; CSS resume as a full-page digital resume.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fi75j1grhg6ayt0mqd2rs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fi75j1grhg6ayt0mqd2rs.png" alt="Alt Text" width="361" height="334"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note:&lt;/em&gt;  When designing your new resume, it's best to work with a custom viewport in the dev tools rather than having to go into print preview every time to see how it will look on paper - You can set it to 825 x 1175 to correspond to the paper size.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Femq5y2far80gqb3hlj0q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Femq5y2far80gqb3hlj0q.png" alt="Alt Text" width="424" height="47"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note 2:&lt;/em&gt; This only works in Chrome as right now I can't see a way to do a full-bleed print to PDF in Firefox...&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Final added benefits to convince you:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;All &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; tag links in your web page will &lt;em&gt;still&lt;/em&gt; function as working links in your final PDF&lt;/li&gt;
&lt;li&gt;Instead of being stuck with MS Office, you can create your resume with whatever tool you're comfortable with; Sass, Tailwind, hell - even Bootstrap! (I'm &lt;em&gt;definitely&lt;/em&gt; not saying you should, I'm just... saying that you &lt;em&gt;can&lt;/em&gt;)&lt;/li&gt;
&lt;li&gt;You can have your own custom backgrounds to make your resume stand out. Go with lots of colours to funk it up, or maybe choose a textured off-white background for something a little more classy.
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fhifnuw73wzmr6zvgj8bz.gif" alt="Alt Text" width="480" height="300"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So there you have it! Go get creative, use those dev skills and actually &lt;em&gt;enjoy&lt;/em&gt; writing your CV for once :-)&lt;/p&gt;

</description>
      <category>resume</category>
      <category>career</category>
      <category>codenewbie</category>
      <category>css</category>
    </item>
    <item>
      <title>The Art of Centering</title>
      <dc:creator>Ciaran Concannon</dc:creator>
      <pubDate>Mon, 03 Aug 2020 16:52:09 +0000</pubDate>
      <link>https://forem.com/cjcon90/the-art-of-centering-3epe</link>
      <guid>https://forem.com/cjcon90/the-art-of-centering-3epe</guid>
      <description>&lt;p&gt;Like any good Wes Anderson flick, sometimes it's important for elements on our page to utilise the art of symmetry and draw our users' eyes to the center of the page.&lt;/p&gt;

&lt;p&gt;There are a few different methods to achieve this so here I'm going to try and explain the most simple and most useful methods that exist, and also &lt;em&gt;why&lt;/em&gt; they do what they do!&lt;/p&gt;

&lt;p&gt;Here's a quick codepen to show the methods I'll be discussing below:&lt;br&gt;
&lt;iframe height="600" src="https://codepen.io/cjcon90/embed/vYGBmJB?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Auto margins
&lt;/h2&gt;

&lt;p&gt;We'll start with the very common &lt;code&gt;margin: 0 auto&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This is used to quickly and easily &lt;strong&gt;horizontally center block-level elements&lt;/strong&gt;; which are elements on a page that always start on a new line and take up the full width available within their container.&lt;/p&gt;

&lt;p&gt;This is a super useful method as many HTML elements are block-level by default, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; - &lt;code&gt;&amp;lt;h6&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;form&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;header&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;footer&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;section&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To explain &lt;code&gt;margin: 0 auto&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;0&lt;/strong&gt; refers to the top and bottom margins&lt;br&gt;
&lt;strong&gt;auto&lt;/strong&gt; refers to the left and right margins.&lt;/p&gt;

&lt;p&gt;As block level elements take up the full width of their container, auto will give an equal margin to both the left and right of an element - thus, centering it!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: unless you need a specific margin on the top and bottom of your element then you can just as easily write &lt;code&gt;margin: auto&lt;/code&gt;, which will apply an automatic margin to all sides of an element and generally achieve the same result!&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Text align
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;"Wait, wait - I *think* I know how to center text already!"&lt;/em&gt;, I hear you say. Well did you know that &lt;code&gt;text-align: center;&lt;/code&gt; can be used for much more than that?&lt;/p&gt;

&lt;p&gt;There are many important HTML elements that are set as &lt;strong&gt;inline&lt;/strong&gt; display by default for which the above auto margin trick will not work. These include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;textarea&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;select&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Besides that, you may often want to have an element such as a &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; display as an &lt;strong&gt;inline-block&lt;/strong&gt; for various styling or layout purposes, usually if you want to display other elements on the same line within that container.&lt;/p&gt;

&lt;p&gt;When that time comes, all you need to do is use &lt;code&gt;text-align: center;&lt;/code&gt; on the parent element, and it will horizontally center the child element, no matter what it is, the same way that it would text!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: Compared to &lt;code&gt;display: inline&lt;/code&gt;, the major difference is that &lt;code&gt;inline-block&lt;/code&gt; allows to set a width and height on the element and it respects margin and padding. Try changing the display to inline in the CodePen to see the difference between the two!&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Flexbox
&lt;/h2&gt;

&lt;p&gt;Flexbox is a fantastic tool to center or position elements in most situations, however it can be confusing for people as to which flex properties are used when centering an element either vertically, horizontally or both!&lt;/p&gt;

&lt;p&gt;The reason being: this will depend on the what you have set as &lt;code&gt;flex-direction&lt;/code&gt;. To explain:&lt;/p&gt;

&lt;p&gt;If you have a container set as &lt;code&gt;flex-direction: row&lt;/code&gt; (the default setting) then your &lt;strong&gt;main axis&lt;/strong&gt; is the horizontal x-axis, and your &lt;strong&gt;cross-axis&lt;/strong&gt; is the vertical y-axis.&lt;/p&gt;

&lt;p&gt;If you change this setting to &lt;code&gt;flex-direction: column&lt;/code&gt;, then the vertical y-axis becomes your &lt;strong&gt;main axis&lt;/strong&gt; and the horizontal x-axis is your &lt;strong&gt;cross axis&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is important for the two main centering properties:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;justify-content:&lt;/code&gt; which positions an element across its &lt;em&gt;main axis&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;align-items:&lt;/code&gt; which positions an element across its &lt;em&gt;cross axis&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Generally, setting both these two properties to &lt;code&gt;center&lt;/code&gt; will always center an element within a flex container, however it's important to remember the key differences between these two properties for perfect positioning!&lt;/p&gt;

&lt;p&gt;If the container is a row and you want to center the element(s) inside horizontally, go with &lt;code&gt;justify-content&lt;/code&gt;! if it's a column and you need to center horizontally, then reach for &lt;code&gt;align-items&lt;/code&gt;. Hopefully now you have a full understanding of the reason why!&lt;/p&gt;
&lt;h2&gt;
  
  
  Grid
&lt;/h2&gt;

&lt;p&gt;With grid, things can get a little trickier when looking at your page as a whole, depending on how many columns and rows you may set, and many people will reach for flexbox &lt;em&gt;within&lt;/em&gt; a grid container to center elements, however I would like to share one very quick and powerful trick for perfectly centering an element within a grid container.&lt;/p&gt;

&lt;p&gt;In addition to giving the container a property of &lt;code&gt;display: grid&lt;/code&gt;, simply add the property of &lt;code&gt;place-items: center&lt;/code&gt;, which will keep any child element perfectly centered.&lt;/p&gt;

&lt;p&gt;A great option for both vertically and horizontally centering an element in any situation!&lt;/p&gt;
&lt;h2&gt;
  
  
  Absolute Centering
&lt;/h2&gt;

&lt;p&gt;I saved my personal favourite for last, due to the flexibility and power in this option. First I'll present the code which I'll explain afterwards:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.container&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;relative&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.child&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;absolute&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;50%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;50%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;translate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;-50%&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;-50%&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;So what's going on here?&lt;/p&gt;

&lt;p&gt;Well firstly we need to remember that whenever we want to use &lt;code&gt;absolute&lt;/code&gt; positioning, it's important that the parent element is set to &lt;code&gt;position: relative&lt;/code&gt;. Otherwise the child element will likely position itself in relation to the whole document body.&lt;/p&gt;

&lt;p&gt;Then we use &lt;code&gt;top: 50%&lt;/code&gt; &amp;amp; &lt;code&gt;left: 50%&lt;/code&gt; to position the child element  at the exact mid-way point of its parent, however that means the element will only &lt;em&gt;begin&lt;/em&gt; at that point (so basically the top left corner of a div).&lt;/p&gt;

&lt;p&gt;To fix this, we use &lt;code&gt;transform: translate(-50%, -50%)&lt;/code&gt; to bring it half-way back on both it's x-axis and y-axis so it is &lt;em&gt;perfectly&lt;/em&gt; centered within it's parent element.&lt;/p&gt;

&lt;p&gt;Two reasons why I love this:&lt;/p&gt;

&lt;p&gt;One, it's flexible - If we wanted to center en element horizontally, then we just use &lt;code&gt;left: 50%&lt;/code&gt;  and use &lt;code&gt;translateX(-50%)&lt;/code&gt; - vice-versa for vertical centering.&lt;/p&gt;

&lt;p&gt;Two, it's &lt;em&gt;perfect&lt;/em&gt; for creating useful mixins with Sass/SCSS. For example I have the following go-to mixins on any project I'm working on for quick and easy centering when I need it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scss"&gt;&lt;code&gt;&lt;span class="k"&gt;@mixin&lt;/span&gt; &lt;span class="nf"&gt;xCenter&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;absolute&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;50%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;translateX&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;-50%&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;@mixin&lt;/span&gt; &lt;span class="nf"&gt;yCenter&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;absolute&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;50%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;translateY&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;-50%&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;@mixin&lt;/span&gt; &lt;span class="nf"&gt;absCenter&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;absolute&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;50%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;50%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;translate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;-50%&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="m"&gt;-50%&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;then any time we need to center an element perfectly, we can simply just use &lt;code&gt;@include absCenter&lt;/code&gt; and hey presto! &lt;/p&gt;

&lt;p&gt;I really hope that was helpful and message if there's any other useful tips, tricks or CSS magic that you think should be included!&lt;/p&gt;

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