<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Lauralee Flores</title>
    <description>The latest articles on DEV Community by Lauralee Flores (@flores8).</description>
    <link>https://dev.to/flores8</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%2F67423%2F35acdbe7-f835-45a7-a0fa-d87ed9509fc4.jpg</url>
      <title>DEV Community: Lauralee Flores</title>
      <link>https://dev.to/flores8</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/flores8"/>
    <language>en</language>
    <item>
      <title>Guide to Properly Size Your Hero Images and Optimize Them for Site Speed</title>
      <dc:creator>Lauralee Flores</dc:creator>
      <pubDate>Thu, 24 May 2018 13:42:58 +0000</pubDate>
      <link>https://dev.to/flores8/guide-to-properly-size-your-hero-images-and-optimize-them-for-site-speed-39a4</link>
      <guid>https://dev.to/flores8/guide-to-properly-size-your-hero-images-and-optimize-them-for-site-speed-39a4</guid>
      <description>&lt;p&gt;If you're like me you've run into this too many times to count. &lt;/p&gt;

&lt;p&gt;Your web page needs a new image for the hero section or top part of your page. You want this image to be large enough for any size screen but not so large that it will significantly slow down the load time on your page. You don't want it too tall either. &lt;/p&gt;

&lt;p&gt;You've done this a bunch of times but each time you open up your design tool to create your hero image, you can never remember what size that hero image should be. &lt;/p&gt;

&lt;p&gt;You know the first thing is to get the dimensions of the image right. &lt;/p&gt;

&lt;h3&gt;
  
  
  Hero Background Dimensions
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fphotos.lauraleeflores.com%2Fn9bS%2Fhero_bg_image.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fphotos.lauraleeflores.com%2Fn9bS%2Fhero_bg_image.jpg" alt="Example of a hero background image"&gt;&lt;/a&gt;&lt;br&gt;
If your image is going to be header/hero background image you'll want to maintain a 16:9 aspect ratio. I make my header images 1600 x 500px. &lt;/p&gt;
&lt;h3&gt;
  
  
  Full Page Background Image Size
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fphotos.lauraleeflores.com%2Fn9dE%2Ffull_page_bg_image.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fphotos.lauraleeflores.com%2Fn9dE%2Ffull_page_bg_image.jpg" alt="Example of Full Page background Image"&gt;&lt;/a&gt;&lt;br&gt;
If you're creating a full page background image you'll want to maintain a 4:3 aspect ratio and I make these images 1600 x 1000px or sometimes 1920 x 1200px. I usually do both sizes and then compress them. If the larger image compresses well and isn't too large I go with the larger image. &lt;/p&gt;
&lt;h3&gt;
  
  
  Mobile Image Size
&lt;/h3&gt;

&lt;p&gt;Depending on how things respond and look on mobile I will sometimes switch out the hero image on mobile (using a media query) to use the correct aspect ratio for smaller screens. I typically make these mobile images 800 x 1200px. &lt;/p&gt;

&lt;p&gt;You can swap out hero images like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.hero-image {
  background: url('my-hero-image.jpg') no-repeat center top;
  background-size: cover;
}
@media (max-width: 768px) {
  background: url('my-mobile-hero-image.jpg') no-repeat center top;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This would show your background image until the screen size is down to 768px wide. And then anything smaller than 768px wide view port the hero image will instead show the mobile image. &lt;/p&gt;

&lt;h3&gt;
  
  
  Download Sketch File
&lt;/h3&gt;

&lt;p&gt;In order to save yourself time and energy from having to search for this next time you have to create your next header, just &lt;a href="http://photos.lauraleeflores.com/n8Ji/hero_image_template.sketch" rel="noopener noreferrer"&gt;download this sketch template&lt;/a&gt;. The template has an artboard for each a header image, a full page image and a mobile image.  &lt;/p&gt;

&lt;p&gt;Save it someplace you will know to look for it the next time you will need to create an image for your website. So that next time you need to create a new image you only have to open up this sketch file and you're off. &lt;/p&gt;

&lt;h3&gt;
  
  
  Image Optimization
&lt;/h3&gt;

&lt;p&gt;Once you know the height and width of your image you want to shift your focus on keeping the size of the image small enough.&lt;/p&gt;

&lt;p&gt;Sometimes a jpg is smaller and sometimes a png is smaller. Typically, for this type of image the jpg is going to be smaller. But, if you're unsure export both the jpg and the png. Use which ever one is smaller naturally for the next step. &lt;/p&gt;

&lt;p&gt;Now you'll want to compress your image to make it the smallest possible size without making it pixelated. As a general rule try to reduce the size of your image to be at around or smaller than 400 kb. &lt;/p&gt;

&lt;h3&gt;
  
  
  Image Compression Tools
&lt;/h3&gt;

&lt;p&gt;If you haven't done this a thousand times already you should do this for every single image you put up on your website. Every time you do this you are in essense speeding up the load time of your web pages. &lt;/p&gt;

&lt;p&gt;If you don't have a tool you can use &lt;a href="https://tinypng.com/" rel="noopener noreferrer"&gt;Tiny PNG&lt;/a&gt;. I personally prefer to have the tool on my computer to use anywhere and anytime without the need for an internet connection. That's why I use &lt;a href="https://itunes.apple.com/us/app/png-compressor/id434886325?mt=12" rel="noopener noreferrer"&gt;PNG Compressor&lt;/a&gt; (macOS app) for all my images that are png. I use &lt;a href="https://itunes.apple.com/us/app/compress/id405850942?mt=12" rel="noopener noreferrer"&gt;Compressor&lt;/a&gt; (macOS app) if the image is a jpg.&lt;/p&gt;

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

&lt;p&gt;&lt;a href="http://photos.lauraleeflores.com/n8Ji/hero_image_template.sketch" rel="noopener noreferrer"&gt;Download this sketch template&lt;/a&gt; of each of the header images you will likely use for each page. Once you've downloaded the image export it and compress it so that it's the smallest size it can be without being pixelated (hopefully less than 400kb). And remember only put images on your website that have been compressed. &lt;/p&gt;

</description>
      <category>css</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How to Vertically Align Anything with CSS</title>
      <dc:creator>Lauralee Flores</dc:creator>
      <pubDate>Wed, 25 Apr 2018 02:20:31 +0000</pubDate>
      <link>https://dev.to/flores8/how-to-vertically-align-anything-with-css-i78</link>
      <guid>https://dev.to/flores8/how-to-vertically-align-anything-with-css-i78</guid>
      <description>&lt;p&gt;Whether you’re an established web developer or new to creating websites you may have thought you knew how to vertically align… &lt;a href="http://www.quickmeme.com/meme/3rdv7x/"&gt;for a minute&lt;/a&gt;. But don’t worry, it happens to us all. &lt;/p&gt;

&lt;p&gt;Here’s my three favorite ways to vertically align stuff in css. &lt;/p&gt;

&lt;h3&gt;
  
  
  Transform
&lt;/h3&gt;

&lt;p&gt;If you’ve been doing web development for a while you’re no doubt familiar with this approach. Before flexbox or css grid this was the only sure way to vertically align in css. Don’t let that fool you though, I still use it today.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.parent {
    position: relative;
}
.child {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you find when using this approach that elements become blurry because they’re placed on a half pixel, try this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; .parent {
    position: relative;
 }
 .child {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: perspective(1px) translate(-50%, -50%);
 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Flexbox
&lt;/h3&gt;

&lt;p&gt;To center an object using flexbox you just need two centering properties:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.element {
     display: flex;
     justify-content: center;
     align-items: center;
 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  CSS Grid
&lt;/h3&gt;

&lt;p&gt;This is such an easy way to center something. This will center the immediate child of this element. If, there are five children inside this element and each of the children have two children. It will center only the five children (not the two nested inside).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.element {
   display: grid;
   place-items: center;
   height: 100vh; // or however tall you want your box to be
 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Aligning just one line of text?
&lt;/h3&gt;

&lt;p&gt;If you are simply trying to vertically align text inside some element it is much easier. All you need to do is give the text the same line-height as the container it’s in. &lt;/p&gt;

&lt;p&gt;For example, if the text is inside a button and the button is 32px tall. Just give the text a line-height of 32px and it will be vertically centered.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.button {
    height: 32px;
 } 
 .text {
   line-height: 32px;
 } 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I hope this helps you as you center things in CSS. Which method did you end up going with? Let me know. &lt;/p&gt;

</description>
      <category>css</category>
      <category>beginners</category>
      <category>webdev</category>
      <category>frontend</category>
    </item>
  </channel>
</rss>
