<?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: mark l chaves</title>
    <description>The latest articles on Forem by mark l chaves (@marklchaves).</description>
    <link>https://forem.com/marklchaves</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%2F272844%2F5ded69be-69cd-4d2f-809f-852b83fe40fa.jpeg</url>
      <title>Forem: mark l chaves</title>
      <link>https://forem.com/marklchaves</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/marklchaves"/>
    <language>en</language>
    <item>
      <title>How to Unset CSS Overflow Using JavaScript when Sticky Elements Stop Working</title>
      <dc:creator>mark l chaves</dc:creator>
      <pubDate>Sat, 06 Mar 2021 22:15:36 +0000</pubDate>
      <link>https://forem.com/marklchaves/how-to-unset-css-overflow-using-javascript-when-sticky-elements-stop-working-iah</link>
      <guid>https://forem.com/marklchaves/how-to-unset-css-overflow-using-javascript-when-sticky-elements-stop-working-iah</guid>
      <description>&lt;p&gt;If your sticky sidebar, header, or footer CTAs stopped working, there's a good chance that your theme added the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/overflow" rel="noopener noreferrer"&gt;CSS overflow property&lt;/a&gt; to a parent element (usually a div).&lt;/p&gt;

&lt;p&gt;Does this sound familiar? Then, keep reading ;-)&lt;/p&gt;

&lt;p&gt;In this tutorial, we'll use JavaScript to unset that &lt;em&gt;bad boy&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;The steps below use WordPress as an example. But, the same concept applies to other website platforms or frameworks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Find the Offending Element
&lt;/h2&gt;

&lt;p&gt;Open your dev tools and type in &lt;code&gt;overflow&lt;/code&gt; in the search filter for the CSS panel.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fcyync81bdg631slm7g7c.png" 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/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcyync81bdg631slm7g7c.png" alt="Finding the overflow property using the browser inspector tool"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Make a note of the HTML ID attribute of the element that has the &lt;code&gt;overflow&lt;/code&gt; property set.&lt;/p&gt;

&lt;p&gt;In this case, it's &lt;code&gt;boxed-wrapper&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Write the JavaScript to Unset the Overflow Property
&lt;/h2&gt;

&lt;p&gt;Open your favourite code editor. Copy and paste the code below into your editor and save it using the &lt;code&gt;.js&lt;/code&gt; file extension.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;URL&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;floating-toc-sidebar-test&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;element&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;boxed-wrapper&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;overflow&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;unset&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="cm"&gt;/* To fix any position: sticky further down the DOM. */&lt;/span&gt;
&lt;span class="p"&gt;})();&lt;/span&gt;        
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Change &lt;code&gt;floating-toc-sidebar-test&lt;/code&gt; to your page slug. This is because we want this code to run only on the page that needs fixing.&lt;/p&gt;

&lt;p&gt;Change &lt;code&gt;boxed-wrapper&lt;/code&gt; to the HTML ID you noted in &lt;strong&gt;Step 1&lt;/strong&gt;. Note: If the offending HTML element didn't have an ID, you'll need to come up with a CSS selector that grabs that one element only.&lt;/p&gt;

&lt;p&gt;Save your file again.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Install the JavaScript Code
&lt;/h2&gt;

&lt;p&gt;There are 2 options.&lt;/p&gt;

&lt;h3&gt;
  
  
  Option 1: Installing Without a Plugin
&lt;/h3&gt;

&lt;p&gt;Open your favourite code editor again. Copy and paste the code below and save it using the &lt;code&gt;.php&lt;/code&gt; file extension.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;/* Inline script printed out in the footer to fix sticky elements. */
function sticky_fix_add_script_wp_footer() {
    ?&amp;gt;
        &lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
            &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;URL&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;floating-toc-sidebar-test&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;element&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;boxed-wrapper&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                &lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;overflow&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;unset&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="cm"&gt;/* To fix any position: sticky further down the DOM. */&lt;/span&gt;
            &lt;span class="p"&gt;})();&lt;/span&gt;        
        &lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
    &lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nf"&gt;add_action&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'wp_footer'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'sticky_fix_add_script_wp_footer'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace the function between the &lt;code&gt;&amp;lt;script&amp;gt;&amp;lt;/script&amp;gt;&lt;/code&gt; tags with the function  you wrote in &lt;strong&gt;Step 2&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Save your PHP file.&lt;/p&gt;

&lt;p&gt;Copy and paste the contents of your PHP file into your child theme's &lt;code&gt;functions.php&lt;/code&gt; file.&lt;/p&gt;

&lt;h3&gt;
  
  
  Option 2: Installing Using the Insert Headers and Footer Plugin
&lt;/h3&gt;

&lt;p&gt;Log into your WordPress admin area. Head over to &lt;strong&gt;Settings&lt;/strong&gt; &amp;gt; &lt;strong&gt;Insert Headers and Footers&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In the &lt;strong&gt;Scripts in Footer&lt;/strong&gt; code snippet box at the bottom, type in the following code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, copy/paste the JavaScript code that you wrote in &lt;strong&gt;Step 2&lt;/strong&gt; between the &lt;code&gt;&amp;lt;script&amp;gt;&amp;lt;/script&amp;gt;&lt;/code&gt; tags.&lt;/p&gt;

&lt;p&gt;Here's what you should have so far.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fk6h5m1ktjhiecj9adwg4.png" 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/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk6h5m1ktjhiecj9adwg4.png" alt="Adding JavaScript to the footer using a plugin"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hit &lt;strong&gt;Save&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;And, you're &lt;strong&gt;done&lt;/strong&gt; and &lt;em&gt;done&lt;/em&gt;!&lt;/p&gt;

&lt;p&gt;Give your page a test. &lt;/p&gt;

&lt;p&gt;Remember to share your knowledge with others who run into the same problem.&lt;/p&gt;

&lt;p&gt;Enjoy!&lt;/p&gt;

</description>
      <category>html</category>
      <category>css</category>
      <category>wordpress</category>
      <category>javascript</category>
    </item>
    <item>
      <title>How to Send a Custom Event to Google Analytics 4 Using JavaScript</title>
      <dc:creator>mark l chaves</dc:creator>
      <pubDate>Wed, 20 Jan 2021 11:05:45 +0000</pubDate>
      <link>https://forem.com/marklchaves/how-to-send-a-custom-event-to-google-analytics-4-using-javascript-2eh</link>
      <guid>https://forem.com/marklchaves/how-to-send-a-custom-event-to-google-analytics-4-using-javascript-2eh</guid>
      <description>&lt;h2&gt;
  
  
  Intro
&lt;/h2&gt;

&lt;p&gt;This article is a quick demo of how you can send a custom event to Google Analytics 4 (GA4) using just pure JavaScript. &lt;/p&gt;

&lt;p&gt;I've only seen one other article describing something similar. But, that implementation used Google Tag Manager. I wanted to do the same thing using pure JavaScript instead.&lt;/p&gt;

&lt;p&gt;You’ll also learn how to see custom events in GA4 via the &lt;strong&gt;DebugView&lt;/strong&gt;, &lt;strong&gt;Events&lt;/strong&gt; report, and a &lt;em&gt;custom&lt;/em&gt; report.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Scenario: Menu Clicks
&lt;/h2&gt;

&lt;p&gt;Everything is an event in GA4. GA4 recognises &lt;a href="https://developers.google.com/analytics/devguides/collection/ga4/events" rel="noopener noreferrer"&gt;3 categories of events&lt;/a&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Automatically collected events&lt;/li&gt;
&lt;li&gt;Recommended events&lt;/li&gt;
&lt;li&gt;Custom events&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Google recommends using events from these 3 categories in the above order. Top-level menu clicks aren't in the first 2, so they're a great candidate for this tutorial.&lt;/p&gt;

&lt;p&gt;All righty then. Let's track menu clicks by sending them as custom events to a GA4 property!&lt;/p&gt;

&lt;h3&gt;
  
  
  Identifying Menu Items in the Twenty Twenty Theme
&lt;/h3&gt;

&lt;p&gt;In the WordPress Twenty Twenty and Twenty Twenty-One themes we can use the &lt;em&gt;menu-item- ...&lt;/em&gt; ID values.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fxa87pyqig399cszpy4vw.png" 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/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fxa87pyqig399cszpy4vw.png" alt="Using the menu-item-nn ID values to grab the menu items"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Based on this HTML code, we can use this CSS selector for grabbing menu item elements.&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="nt"&gt;li&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;id&lt;/span&gt;&lt;span class="o"&gt;^=&lt;/span&gt;&lt;span class="s2"&gt;'menu-item-'&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;a&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The Code
&lt;/h2&gt;

&lt;p&gt;Now that we know how to grab the menu items, we can hook them up with event listeners and callbacks.&lt;/p&gt;

&lt;p&gt;Inside the event callback code, we'll need to add our call to gtag.js. It will look like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;gtag&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;event&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;MenuClick&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;menu_item_name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;menu_item_url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;url&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;In the code snippet above, we send an event called &lt;em&gt;MenuClick&lt;/em&gt; along with 2 parameters for the name of the menu item (i.e., menu item text) and the URL of the menu item.&lt;/p&gt;

&lt;p&gt;The full algorithm is in the JavaScript snippet below and is available as a &lt;a href="https://gist.github.com/marklchaves/1ec73bdede21b85b59c37193492931ef" rel="noopener noreferrer"&gt;gist on Github&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;gtag&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;undefined&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;// Grab all the menu items on Twenty Twenty WordPress theme page.&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;menuElts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelectorAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;li[id^='menu-item-'] &amp;gt; a&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`I found &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;menuElts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; menu items to process.`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// JavaScript template literal for printing inline JS expression.&lt;/span&gt;

  &lt;span class="c1"&gt;// If no menu items, bail.&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;menuElts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;// Convert to an array so we can map over the array&lt;/span&gt;
  &lt;span class="c1"&gt;// if you don't want to use the spread syntax.&lt;/span&gt;
  &lt;span class="c1"&gt;// let menuItemsArr = Array.from(menuElts);&lt;/span&gt;
  &lt;span class="c1"&gt;// menuItemsArr.map((elt) =&amp;gt; {&lt;/span&gt;

  &lt;span class="c1"&gt;// Spread and map.&lt;/span&gt;
  &lt;span class="p"&gt;[...&lt;/span&gt;&lt;span class="nx"&gt;menuElts&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;elt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Set up the listener and handler at the same time.&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;elt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;click&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;evt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Sending menu click to GA4.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;evt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerText&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;evt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;href&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="c1"&gt;// DEBUG&lt;/span&gt;
        &lt;span class="c1"&gt;// evt.preventDefault(); // Don't navigate!&lt;/span&gt;
        &lt;span class="c1"&gt;// console.log(`Menu item clicked: ${name} ${url}`);&lt;/span&gt;

        &lt;span class="nf"&gt;gtag&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;event&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;MenuClick&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="na"&gt;menu_item_name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;menu_item_url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;url&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;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Something wrong happened when setting up event handling for the menu items.&lt;/span&gt;&lt;span class="dl"&gt;"&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;span class="p"&gt;})();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The Result
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Viewing the Result in the Debugger
&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/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F9xs7uvqwfpnrvddiv2zm.png" 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/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F9xs7uvqwfpnrvddiv2zm.png" alt="DebugView"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Viewing the Result in Engagement &amp;gt; Events
&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/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fvt8ihsccsg3v2fdr0gr5.png" 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/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fvt8ihsccsg3v2fdr0gr5.png" alt="Engagement &amp;gt; Events report"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating a Custom Report in the Analysis Hub
&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/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fed1s1ad4m87nl1fs1slj.png" 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/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fed1s1ad4m87nl1fs1slj.png" alt="The custom menu click report in the Analysis hub"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Credits
&lt;/h2&gt;

&lt;p&gt;The use case and workflow are based on Julius Fedorovicius' article &lt;a href="https://www.analyticsmania.com/post/how-to-track-custom-events-with-google-analytics-4/" rel="noopener noreferrer"&gt;How to Track Custom Events with Google Analytics 4&lt;/a&gt; posted on Analytics Mania.&lt;/p&gt;

&lt;p&gt;Cover image: &lt;em&gt;Custom&lt;/em&gt; scrambler with model Tara photographed by mark l chaves.&lt;/p&gt;

</description>
      <category>wordpress</category>
      <category>googleanalytics</category>
      <category>ga4</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Why Having a Staging Site Is Good for Your Sanity</title>
      <dc:creator>mark l chaves</dc:creator>
      <pubDate>Mon, 02 Nov 2020 00:11:06 +0000</pubDate>
      <link>https://forem.com/marklchaves/why-having-a-staging-site-is-good-for-your-sanity-102g</link>
      <guid>https://forem.com/marklchaves/why-having-a-staging-site-is-good-for-your-sanity-102g</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Don't want to lose sleep over your website going down? Get a staging site.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You have a successful website. You're happy because you got your site up and running quickly on a tight budget. &lt;/p&gt;

&lt;p&gt;Now, your website is the main source of your customers and sales. As your business grows so does your need for more functionality and plugins. &lt;/p&gt;

&lt;p&gt;A few times a month, you make content updates and do software upgrades to your site all by yourself. You've never had any problems—you think running a website is a piece of cake. &lt;/p&gt;

&lt;h2&gt;
  
  
  The Nightmare
&lt;/h2&gt;

&lt;p&gt;Then, one day after you just updated a dozen or so plugins, you start getting emails from customers, WordPress, and even Google. The emails say that you have a serious issue with your site. &lt;/p&gt;

&lt;p&gt;You bring up your browser and try to pull up your site. All you get is a blank white screen. &lt;/p&gt;

&lt;p&gt;This nightmare scenario happens all too often. The good news is, it can easily be avoided if you use what's called a staging site or staging environment. &lt;/p&gt;

&lt;h2&gt;
  
  
  Use a Separate Copy of Your Live Site
&lt;/h2&gt;

&lt;p&gt;A staging site is a separate copy of your live website. The key words being: &lt;strong&gt;separate&lt;/strong&gt; and &lt;strong&gt;copy&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;Because a staging site is separate from your live site, you can do things like upgrading WordPress, your theme, and your installed plugins without affecting your live site. And, since a staging site is a copy of your live site, you can make changes and test the changes on a staging site as if it was your live site. &lt;/p&gt;

&lt;h2&gt;
  
  
  The Benefits of a Staging Site
&lt;/h2&gt;

&lt;p&gt;After you verify that the changes you made on staging look good and work the way they should, then you can make those same changes on the live site. Testing updates on a staging site before applying the updates on your live site helps ensure:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Your site is still fully functional and continuing to deliver your online offerings.&lt;/li&gt;
&lt;li&gt;There's no disruption of your online presence that you rely on to promote your brand awareness and preserve your credibility.&lt;/li&gt;
&lt;li&gt;There's no loss of revenue and customers because of unplanned downtime.&lt;/li&gt;
&lt;li&gt;No search engine penalties from non-working pages or missing content (e.g., 404 or 500 errors).&lt;/li&gt;
&lt;li&gt;There's no loss of precious site content or customer data—namely for membership and eCommerce sites.&lt;/li&gt;
&lt;li&gt;Your brand, credibility, and domain authority are protected.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Your Live Site Shouldn’t be Your Test Site
&lt;/h2&gt;

&lt;p&gt;Staging sites don't have to be just for testing plugin updates. They can be an entire development environment for a new site, a place for troubleshooting and fixing an issue, or even a performance and scalability testing lab. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If you care about your business and your customers, you shouldn't be experimenting or making untested updates on your live site. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Does the phrase, "a copy of your live site" set off your SEO warning bells? Don't worry. You can password protect staging site (recommended). You can also tell search robots not to index your staging site. That means they won't affect SEO standings of your live site. &lt;/p&gt;

&lt;p&gt;OK, just because you have a staging site doesn't mean you're completely in the clear. They can be misused just like any other tools in your toolkit. &lt;/p&gt;

&lt;p&gt;In this article, I'll guide you through 8 best practices for using a staging site.&lt;/p&gt;

&lt;p&gt;Please note that I'll use the words staging site, staging environment, and staging to all mean the same thing. I'll also refer to the live site as &lt;em&gt;production&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  8 Best Practices for Your Staging Site
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. But First, Take a &lt;del&gt;Selfie&lt;/del&gt; Backup
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CSevPrHt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/v48jbzh3ambzvx1kwpt7.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CSevPrHt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/v48jbzh3ambzvx1kwpt7.jpg" alt="A young Balinese man takes a selfie before a cremation ritual in Ubud, Bali by mark l chaves" title="A young Balinese man takes a selfie before a cremation ritual in Ubud, Bali by mark l chaves" width="880" height="586"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A full backup means that &lt;strong&gt;all&lt;/strong&gt; the files that make up your site are copied to a safe location. This is opposed to a partial backup where you can select to back up only parts of your site. A full backup includes WordPress core files, theme files, media files, and database (DB) files. &lt;/p&gt;

&lt;p&gt;I recommend that you always make a full backup of your live site before creating the staging site copy. You can quickly restore everything back to normal from the full backup if needed. &lt;/p&gt;

&lt;p&gt;You should always take another full backup of your live site when you make any changes to it. &lt;/p&gt;

&lt;p&gt;These full backups are your insurance policy for when the live site becomes &lt;em&gt;corrupted&lt;/em&gt; at any point during the process. &lt;/p&gt;

&lt;p&gt;It's important to note that there's a difference between a daily backup and an instant (unscheduled) backup—sometimes called a &lt;em&gt;snapshot&lt;/em&gt;. A &lt;em&gt;snapshot&lt;/em&gt; taken just before updating the live site is good to practise for minimising data loss. &lt;/p&gt;

&lt;h3&gt;
  
  
  2. Disable Email Notifications
&lt;/h3&gt;

&lt;p&gt;While working in staging, you should disable all email notification. &lt;/p&gt;

&lt;p&gt;You definitely don't want to inadvertently flood your customer's inboxes if the work you're doing on staging is kicking out email notifications all over the place. &lt;/p&gt;

&lt;p&gt;There are plugins that can temporarily disable notifications, yet log them for you as if they are sent. This is an awesome way to test emails without spamming everyone.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Clear Your Cache
&lt;/h3&gt;

&lt;p&gt;It happens to all of us. &lt;/p&gt;

&lt;p&gt;After we make a simple change we reload the page to see it, and it's not there. We hit reload a couple more times—still nothing. &lt;/p&gt;

&lt;p&gt;We go back to the change. The change looks good. &lt;/p&gt;

&lt;p&gt;We hit the save button just to be extra sure. We click reload again. Nothing. &lt;/p&gt;

&lt;p&gt;We're just about the scream before we realise we should clear our caches.&lt;/p&gt;

&lt;p&gt;Assuming your change doesn't have an error, you save your work, and you're looking at the right page, this problem is almost always due to caching. &lt;/p&gt;

&lt;p&gt;To save time and your sanity, I recommend disabling your caches while you are making changes in staging. Only enable them when you are doing performance testing or to make sure there are no plugin conflicts if you use a caching plugin. &lt;/p&gt;

&lt;p&gt;Make sure you clear your caches on the live site too when you push changes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MJtrbyTQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t8twvs1mr67f67rst4ak.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MJtrbyTQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t8twvs1mr67f67rst4ak.jpg" alt="Image description" width="407" height="405"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By the way, when we say &lt;em&gt;caches&lt;/em&gt;, we mean all caches:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Browser&lt;/li&gt;
&lt;li&gt;WordPress&lt;/li&gt;
&lt;li&gt;Server&lt;/li&gt;
&lt;li&gt;Database&lt;/li&gt;
&lt;li&gt;CDN&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To top it off, some plugins build their own asset cache. Check your plugin's setting to see if they have one.&lt;/p&gt;

&lt;p&gt;So, I get this all of the time, "I don't have a cache." Chances are you do and just don't know it yet.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Never Push the Staging DB to Production
&lt;/h3&gt;

&lt;p&gt;Your production database should be the single source of truth. Treat it like your personal gold mine. Therefore, never contaminate it. &lt;/p&gt;

&lt;p&gt;This means, never push your staging database to your live site. &lt;/p&gt;

&lt;p&gt;Overwriting your production data from staging is never a good idea. &lt;/p&gt;

&lt;p&gt;Some automated staging tools don't even permit pushing the staging DB to production. That's a good thing.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Don't Rely Only on Partial Backups
&lt;/h3&gt;

&lt;p&gt;As I mentioned above, full backups are the only way to fly. &lt;/p&gt;

&lt;p&gt;You might see options in your dashboard for backing up only the database, media, theme, or plugins. When it comes to working with staging environments, don't take partial backups. &lt;/p&gt;

&lt;p&gt;You need to make sure you can always restore your complete site—not just pieces of it.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Don't Keep Your Backups on Your Website Server
&lt;/h3&gt;

&lt;p&gt;There are two big reasons you shouldn't keep your full site backup on your website. &lt;/p&gt;

&lt;p&gt;First, if your server crashes and all files are lost, your most recent full backup is also gone. &lt;/p&gt;

&lt;p&gt;Second, your backup file(s) takes up disk space. Depending on the size of your site, your backup files can be humungous. Your available disk space could shrink to nothing if you have an increasing stockpile of backups on your site. &lt;/p&gt;

&lt;p&gt;Your site will screech to grinding halt when you're out of disk space. &lt;/p&gt;

&lt;p&gt;Just say no.&lt;/p&gt;

&lt;h3&gt;
  
  
  7. Restrict Access to Staging
&lt;/h3&gt;

&lt;p&gt;Hosting plans that support staging sites usually create them with private access by default. However, you should always check especially if you manually created your staging site. &lt;/p&gt;

&lt;p&gt;Staging sites should be controlled environments so you know what's happening to the site at all times. Password protect them. &lt;/p&gt;

&lt;p&gt;Otherwise, you can be wasting precious time chasing your tail trying to figure out why the changes you made yesterday aren't working today. &lt;/p&gt;

&lt;p&gt;And please remember. You don't want your staging site to show up on search results either.&lt;/p&gt;

&lt;h3&gt;
  
  
  8. Never do Automatic Updates
&lt;/h3&gt;

&lt;p&gt;If your site is mission-critical, you'll lose revenue and customers when your site goes down.&lt;/p&gt;

&lt;p&gt;You should never automatically update your WordPress version, your active theme, and any active plugins. Having auto-updates turned on is a recipe for disaster.&lt;/p&gt;

&lt;p&gt;You'll need to check with your hosting provider's policy to see what their default update settings are. If they default to any kind of automatic updates, then you'll need to know how to disable them. &lt;/p&gt;

&lt;h2&gt;
  
  
  Parting Thoughts
&lt;/h2&gt;

&lt;p&gt;I recommend that you always use a staging site even for updates that seem completely harmless. Conversely, I don't ever recommend using your live site to test changes or try out new things. &lt;/p&gt;

&lt;p&gt;Unless of course:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Your live site is private and has no visitors except for you.&lt;/li&gt;
&lt;li&gt;Your live site is public, but no one cares if it's up or down.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Cost used to be a factor for skipping staging sites. Luckily, more and more hosting plans include one-click staging environments. &lt;/p&gt;

&lt;p&gt;With more support for staging sites, there's no reason to find out the hard way that running your operations without a staging site is a costly mistake. &lt;/p&gt;

&lt;p&gt;Let's face it, having a website (whether it's on WordPress or not) requires continuous care and feeding. If you want a healthy and safe website that's always running the latest/greatest features, investing in a staging site is a &lt;em&gt;no brainer&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--b-dfYQf0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/xsdwpqw6bs95a7qhtukg.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--b-dfYQf0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/xsdwpqw6bs95a7qhtukg.gif" alt="Websites require continuous care and feeding - Our Millie playing with her ball by mark l chaves" title="Websites require continuous care and feeding - Our Millie playing with her ball by mark l chaves" width="360" height="640"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Websites (like fur babies) need constant care and feeding&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Resources (no affiliations)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  WordPress
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://wpengine.com/resources/what-is-a-staging-site-why-have-one/"&gt;What is a staging site by WP Engine&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://getflywheel.com/layout/wordpress-staging-area/"&gt;Why you need a WordPress staging area and how to use one by Flywheel&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://elementor.com/blog/wordpress-staging-site/"&gt;How to Set Up a WordPress Staging Site by Elementor&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://formidableforms.com/knowledgebase/what-plugins-are-known-to-cause-conflicts/#kb-test-on-a-staging-site"&gt;Formidable Forms says to test on a staging site&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Other
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.netlify.com/products/workflow/"&gt;Netlify&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.vultr.com/docs/creating-a-simple-website-on-vultr-with-openbsd-httpd"&gt;Vultr&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Credits
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;This article is a lean version of the original I wrote for the Uncanny Owl blog.&lt;/li&gt;
&lt;li&gt;Hero image is a photo I made at the Hard Rock Cafe in Kuta, Bali while covering a gig for Mata Jiwa and Navicula in 2018.&lt;/li&gt;
&lt;li&gt;All other images by mark l chaves unless otherwise stated.&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>webdev</category>
      <category>wordpress</category>
      <category>staging</category>
      <category>bestpractice</category>
    </item>
    <item>
      <title>HTML5 Video Tracking by User ID Using Google Tag Manager</title>
      <dc:creator>mark l chaves</dc:creator>
      <pubDate>Fri, 30 Oct 2020 06:42:12 +0000</pubDate>
      <link>https://forem.com/marklchaves/html5-video-tracking-by-user-id-using-google-tag-manager-210m</link>
      <guid>https://forem.com/marklchaves/html5-video-tracking-by-user-id-using-google-tag-manager-210m</guid>
      <description>&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt;: This works with Google Analytics &lt;em&gt;Universal Analytics&lt;/em&gt;. This does &lt;strong&gt;not&lt;/strong&gt; work with &lt;em&gt;GA4&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;The not-so-good news is there isn’t a &lt;em&gt;native&lt;/em&gt; way for Google Analytics to track HTML5 video play events. Yes, even in this day and age where video pretty much rules.&lt;/p&gt;

&lt;p&gt;But, the good news is there is a way to track these events without starting from scratch. You’ll need to be pretty comfortable with Google Tag Manager though ;-).&lt;/p&gt;

&lt;p&gt;I know this stuff has been done before. But, I've added a twist. I'm going to show you how to find out which logged-in WordPress users are watching your HTML5 videos.&lt;/p&gt;

&lt;p&gt;Oh, be sure you've &lt;a href="https://support.google.com/analytics/answer/3123666?hl=en"&gt;enabled user ID tracking&lt;/a&gt; for your Google Analytics property.&lt;/p&gt;

&lt;p&gt;Let's get to it!&lt;/p&gt;

&lt;h2&gt;
  
  
  Don't Reinvent the Wheel
&lt;/h2&gt;

&lt;p&gt;Luckily, we don't have to start from 0. We'll kick things off by using Julius Fedorovicius’ &lt;a href="https://www.analyticsmania.com/google-tag-manager-recipes/html5-video/"&gt;HTML5 Video Tracking Recipe for Google Tag Manager&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;You'll want to follow Julius' instructions in &lt;a href="https://www.analyticsmania.com/google-tag-manager-recipes/html5-video/"&gt;his article&lt;/a&gt;. In step 3, I chose his recommendation to use the &lt;strong&gt;Google Analytics Settings&lt;/strong&gt; variable.&lt;/p&gt;

&lt;p&gt;Now that that's over, we can dig into the fun stuff—adding support for user ID tracking.&lt;/p&gt;

&lt;h2&gt;
  
  
  User ID Support Show &amp;amp; Tell
&lt;/h2&gt;

&lt;p&gt;Here's what my Google Analytics Settings look like.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UC9TyqQJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/m61q44y0co6k4kdbdjxw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UC9TyqQJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/m61q44y0co6k4kdbdjxw.png" alt="GTM Google Analytics Settings" title="GTM Google Analytics Settings"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's a bit of a workhorse. Meaning it's doing 3 things for me:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Pulling in my GA tracking code so that the imported HTML5 Video Player recipe knows which property to send the stats.&lt;/li&gt;
&lt;li&gt;Defining the user ID data layer variable that will store the WordPress logged-in user ID to send to GA during video events.&lt;/li&gt;
&lt;li&gt;Setting up the user ID custom dimension that grabs the user ID (see above) and maps it to the user ID custom dimension I've defined for my property.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  The Glue
&lt;/h2&gt;

&lt;p&gt;This is the data layer variable that glues everything together.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_RmzdqsF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/y92ejjvb5b9h45xnlz29.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_RmzdqsF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/y92ejjvb5b9h45xnlz29.png" alt="GTM User ID Variable" title="GTM User ID Variable"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Since we have the user ID data layer variable, we can add it to the GTM tag JavaScript source code that we imported earlier. You'll want to add it everywhere you see a GA event being set up.&lt;/p&gt;

&lt;p&gt;Here's what you should have.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oi7oQlP1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/y6pc76gpbju2hi2so0e3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oi7oQlP1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/y6pc76gpbju2hi2so0e3.png" alt="GTM Tag JavaScript Source" title="GTM Tag JavaScript Source"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Last Piece.
&lt;/h2&gt;

&lt;p&gt;You're almost there. &lt;/p&gt;

&lt;p&gt;You're probably asking yourself, "How the heck do I get this user ID in the first place?"&lt;/p&gt;

&lt;p&gt;The answer is: From WordPress of course! &lt;/p&gt;

&lt;p&gt;Add this code to your child theme's functions.php file, create a plugin for it, or use a code snippets plugin that supports PHP.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;get_current_user_vid_tracking&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nf"&gt;is_page&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="s1"&gt;'html5-video'&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;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nv"&gt;$current_user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;wp_get_current_user&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;$current_user&lt;/span&gt; &lt;span class="k"&gt;instanceof&lt;/span&gt; &lt;span class="n"&gt;WP_User&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;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nv"&gt;$user_ID&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$current_user&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="no"&gt;ID&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="cp"&gt;?&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;cmeUserID&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt; &lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$user_ID&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="cp"&gt;?&amp;gt;&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Set the user ID using signed-in user_ID.&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
  &lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nf"&gt;add_action&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="s1"&gt;'wp_head'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'get_current_user_vid_tracking'&lt;/span&gt; &lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I do an upfront check for my HTML5 video test page. You'll want to tweak that &lt;code&gt;if&lt;/code&gt; test or remove it if you don't need it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pulling it All Together
&lt;/h2&gt;

&lt;p&gt;Assuming that you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Saved and published your GTM changes, &lt;/li&gt;
&lt;li&gt;Inserted your PHP code, and &lt;/li&gt;
&lt;li&gt;There aren't any coding errors &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When you visit a page on your site that has an HTML5 video, you'll see something like this in the GA Realtime report.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5i5Qp3XV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/37zxbz4pxxfd1j7o32wd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5i5Qp3XV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/37zxbz4pxxfd1j7o32wd.png" alt="Google Analytics Realtime Report" title="Google Analytics Realtime Report"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here's an example Google Analytics custom report showing HTML5 video events grouped by the user ID custom report.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gn9d6vNh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/xnls48kbpkpbk0zpqqxu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gn9d6vNh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/xnls48kbpkpbk0zpqqxu.png" alt="Custom report showing HTML5 video events grouped by the user ID custom dimension" title="custom report showing HTML5 video events grouped by the user ID custom dimension"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You're probably noticing the funky user ID. That's the internal WordPress user ID, and we're using this cryptic number because of &lt;a href="https://support.google.com/analytics/answer/6366371?hl=en"&gt;PII protection&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Not so helpful, eh? But this is WordPress. So, to make life a bit easier, you can add a custom user ID column to your WordPress user admin page. I've got a &lt;a href="https://github.com/marklchaves/cme-user-id-column"&gt;super teenie plugin&lt;/a&gt; that does this for you. &lt;/p&gt;

&lt;p&gt;You'll get something like this if you use this plugin or another similar plugin.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gcEHT8Cw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/marklchaves/cme-user-id-column/main/cme-user-id-column-screengrab-1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gcEHT8Cw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/marklchaves/cme-user-id-column/main/cme-user-id-column-screengrab-1.png" alt="Custom user ID column" title="Custom user ID column"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Extras
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://streetphotography.blog/html5-video/"&gt;See a live demo here.&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  NEW!
&lt;/h3&gt;

&lt;p&gt;There's now a &lt;a href="https://streetphotography.blog/html5-video-plugin/"&gt;standalone WordPress plugin (GA4HTML5VID)&lt;/a&gt; that works completely without Google Tag Manager and still supports user ID tracking.&lt;/p&gt;




&lt;h2&gt;
  
  
  Credits
&lt;/h2&gt;

&lt;p&gt;The HTML5 Video Tracking Recipe is originally from &lt;a href="https://www.thyngster.com/tracking-html5-videos-gtm"&gt;David Vallejo&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>googleanalytics</category>
      <category>webdev</category>
      <category>wordpress</category>
    </item>
    <item>
      <title>A Practical CSS Linear Gradient</title>
      <dc:creator>mark l chaves</dc:creator>
      <pubDate>Thu, 14 May 2020 12:04:31 +0000</pubDate>
      <link>https://forem.com/marklchaves/a-practical-css-linear-gradient-pnm</link>
      <guid>https://forem.com/marklchaves/a-practical-css-linear-gradient-pnm</guid>
      <description>&lt;p&gt;I feel that there's a love-hate relationship with linear gradients. You either love them or hate them.&lt;/p&gt;

&lt;p&gt;In this short tutorial, I think you'll learn to love using gradients for a particular case—the hero image.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;I think big and bold hero images are cool. But if you're not careful, then these images can make the top menu hard to read.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Forrl5i7utf99cntkdy3o.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/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Forrl5i7utf99cntkdy3o.jpg" alt="Hard to read menu items using no linear gradient."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Fix
&lt;/h2&gt;

&lt;p&gt;We can use a &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/linear-gradient" rel="noopener noreferrer"&gt;CSS linear gradient&lt;/a&gt; to darken the &lt;strong&gt;part&lt;/strong&gt; of background image beneath the menu items.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F69jjhzy95dr4cipg8pq9.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/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F69jjhzy95dr4cipg8pq9.jpg" alt="Easier to read menu items using a linear gradient."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I like this solution because:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;It's fast and flexible.&lt;/strong&gt; I don't need to go into Photoshop. Photoshop is a great tool. But, photo editing is a cumbersome step in the workflow. And, if you mess up by making the image too light or not dark enough, you get to fire up Photoshop and edit the image again :-(. On the other hand, If we want to turn off the gradient or if we want to change the colour, we simply edit the CSS. Easy!&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It's responsive.&lt;/strong&gt; The CSS linear gradient is responsive. It's not "baked" into the image. It's a decoupled layer that can respond nicely to different devices. That's the way it should be for responsive web design (RWD).&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  The Code
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/* || Gradient Stuff */&lt;/span&gt;

&lt;span class="nc"&gt;.hero&lt;/span&gt;&lt;span class="nd"&gt;::before&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;""&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
    &lt;span class="c"&gt;/* Control the gradient stops with percentages here. */&lt;/span&gt;
    &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;linear-gradient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="nb"&gt;bottom&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0.65&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="m"&gt;100%&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;0&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;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;right&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="c"&gt;/* I don't want this too high because I only want to darken the top. */&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;300px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.hero&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;whitesmoke&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;text-align&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;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100vh&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;min-height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;550px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;background-repeat&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;no-repeat&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;background-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;cover&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;background-position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&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;background-image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sx"&gt;url(https://marklchaves.files.wordpress.com/2020/01/bali-ubud-pasar-les-1-2-1280w.jpg)&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;
  
  
  Breaking it Down
&lt;/h2&gt;

&lt;p&gt;I define a &lt;code&gt;.hero&lt;/code&gt; CSS class. As you guessed, this class defines the full-height background image.&lt;/p&gt;

&lt;p&gt;I use the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/::before" rel="noopener noreferrer"&gt;before pseudo-element&lt;/a&gt; on the &lt;code&gt;.hero&lt;/code&gt; class. This pseudo-element defines the linear gradient that overlays the hero image.&lt;/p&gt;

&lt;p&gt;The gradient starts at the top as black with 65% opacity. It ends 300 pixels lower as black with 0% opacity (fully transparent). &lt;/p&gt;

&lt;h2&gt;
  
  
  Variations
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. We can create a solid bottom border for the menu.
&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/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fwewv8vln0w2i58mls0em.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/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fwewv8vln0w2i58mls0em.jpg" alt="Creating a solid border with gradient stops."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I do this by specifying start/stop percentages for the two rgba colours. If I set the stopping point (25%) of the first rgba to the starting point (25%) of the second rgba, I create a solid border effect.&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="nt"&gt;background&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;linear-gradient&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;to&lt;/span&gt; &lt;span class="nt"&gt;bottom&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="nt"&gt;rgba&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="err"&gt;65&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="err"&gt;10&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="err"&gt;25&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="nt"&gt;rgba&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="err"&gt;25&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="err"&gt;100&lt;/span&gt;&lt;span class="o"&gt;%);&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Or, how about a softer bottom border?
&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/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fklpw0twkqnvl49dmt9tf.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/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fklpw0twkqnvl49dmt9tf.jpg" alt="Softer bottom border."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, I set the starting point (30%) of the second rgba to slightly lower than the stopping point (25%) of the first rgba. This gives me a softer bottom border.&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="nt"&gt;background&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;linear-gradient&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;to&lt;/span&gt; &lt;span class="nt"&gt;bottom&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="nt"&gt;rgba&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="err"&gt;65&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="err"&gt;10&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="err"&gt;25&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="nt"&gt;rgba&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="err"&gt;30&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="err"&gt;100&lt;/span&gt;&lt;span class="o"&gt;%);&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  In the Wild
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://codepen.io/marklchaves/pen/OJVdWdv" rel="noopener noreferrer"&gt;CodePen&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.caughtmyeye.dev/about/" rel="noopener noreferrer"&gt;caught my eye about page&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;I wish I knew earlier how to do this technique! I think many of us didn't know what keywords to search on. And what's worse is, if you search on CSS linear gradients, the examples that come up aren't practical.&lt;/p&gt;

&lt;p&gt;Thanks for reading. Share &amp;amp; enjoy!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>css</category>
      <category>gradient</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Changing up Wordpress Header Logos Using CSS</title>
      <dc:creator>mark l chaves</dc:creator>
      <pubDate>Sat, 18 Apr 2020 11:56:15 +0000</pubDate>
      <link>https://forem.com/marklchaves/changing-up-header-logos-26c5</link>
      <guid>https://forem.com/marklchaves/changing-up-header-logos-26c5</guid>
      <description>&lt;p&gt;Here's another &lt;em&gt;fave&lt;/em&gt; question I get a lot. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;How do you change the site header logo to another logo for a specific page or post?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let's see how you could do this in the &lt;strong&gt;Avada&lt;/strong&gt;, &lt;strong&gt;Divi&lt;/strong&gt;, &lt;strong&gt;Astra&lt;/strong&gt;, and &lt;strong&gt;Twenty Twenty&lt;/strong&gt;. All four methods are CSS-only solutions. I've included three snippets using a &lt;strong&gt;page&lt;/strong&gt; for the example and one snippet using a &lt;strong&gt;post&lt;/strong&gt; for the example. See the comments in the code for how to apply the CSS for &lt;strong&gt;posts&lt;/strong&gt; or &lt;strong&gt;pages&lt;/strong&gt; as needed.&lt;/p&gt;

&lt;p&gt;How do I get the page/post ID?&lt;/p&gt;

&lt;p&gt;Scope out &lt;a href="https://codepen.io/marklchaves/pen/poJWYym"&gt;this pen&lt;/a&gt;, for a &lt;strong&gt;JavaScript&lt;/strong&gt; approach.&lt;/p&gt;

&lt;p&gt;If you want to follow along, here's the logo I'll be using to override the default site logo.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://balistreetphotographer.com/branding/"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HQmidXtq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://balistreetphotographer.files.wordpress.com/2019/02/balistreetphotographer-logo-2-slashes-65.png" alt="Bali Street Photographer Logo" title="Bali Street Photographer Logo"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One &lt;strong&gt;caveat&lt;/strong&gt;: for all custom CSS added to any theme, you may need the &lt;code&gt;!important&lt;/code&gt; directive. You can always use your &lt;a href="https://developer.mozilla.org/en-US/docs/Tools"&gt;Firefox&lt;/a&gt; or &lt;a href="https://developers.google.com/web/tools/chrome-devtools/"&gt;Chrome&lt;/a&gt; dev tools inspector to verify what to override.&lt;/p&gt;

&lt;p&gt;For example, if your logo doesn't show up at first, you might have to use &lt;code&gt;!important&lt;/code&gt; in the code I provide below especially for the display, width, and height attributes.&lt;/p&gt;

&lt;p&gt;Ready? Let's rock!&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Different Logo for Different Pages using Avada #
&lt;/h2&gt;

&lt;p&gt;This CSS will change the logo only for a page on an Avada site that's ID is 18.&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="c"&gt;/* Avada */&lt;/span&gt;

&lt;span class="c"&gt;/** 
 * Hide the default logo. 
 *
 * For posts use .postid-2466 format.
 */&lt;/span&gt;
&lt;span class="nc"&gt;.page-id-18&lt;/span&gt; &lt;span class="nc"&gt;.fusion-logo-link&lt;/span&gt; &lt;span class="nt"&gt;img&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="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/** 
 * Drop in a different logo.
 *
 * The site link is respected.
 */&lt;/span&gt;
&lt;span class="nc"&gt;.page-id-18&lt;/span&gt; &lt;span class="nc"&gt;.fusion-logo-link&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;background-image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sx"&gt;url(https://balistreetphotographer.files.wordpress.com/2019/02/balistreetphotographer-logo-2-slashes-65.png)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;background-repeat&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;no-repeat&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;background-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&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="nb"&gt;block&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="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;65px&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;65px&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;h3&gt;
  
  
  The Result
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--r6YlFtPN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/rf6keyw2f6bvaayf7lgj.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--r6YlFtPN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/rf6keyw2f6bvaayf7lgj.jpg" alt="Avada - Changing the Logo for a Specific Page" title="Avada"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Different Logo for Different Posts using Divi #
&lt;/h2&gt;

&lt;p&gt;For Divi, let's do something exciting and change the logo for a specific &lt;strong&gt;post&lt;/strong&gt; not a page. This CSS will change the logo only for a post on a Divi site that's ID is 266.&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="c"&gt;/* Divi */&lt;/span&gt;

&lt;span class="c"&gt;/**
 * Hide the default logo. 
 *
 * For pages, use format .page-id-9
 */&lt;/span&gt;
 &lt;span class="nc"&gt;.postid-266&lt;/span&gt; &lt;span class="nf"&gt;#logo&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="nb"&gt;none&lt;/span&gt; &lt;span class="cp"&gt;!important&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/** 
 * Insert a different logo as a background image.
 *
 * The site link is respected. 
 */&lt;/span&gt;
&lt;span class="nc"&gt;.postid-266&lt;/span&gt; &lt;span class="nc"&gt;.logo_container&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;background-image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sx"&gt;url(https://balistreetphotographer.files.wordpress.com/2019/02/balistreetphotographer-logo-2-slashes-65.png)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;background-repeat&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;no-repeat&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;100px&lt;/span&gt; &lt;span class="cp"&gt;!important&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;h3&gt;
  
  
  The Result
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tZFa9PdS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ab6tnuqtpgrl8qr6ny0f.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tZFa9PdS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ab6tnuqtpgrl8qr6ny0f.jpg" alt="Divi - Changing the Logo for a Specific Post" title="Divi"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Different Logo for Different Pages using Astra #
&lt;/h2&gt;

&lt;p&gt;This CSS will change the logo only for a page on an Astra site that's ID is 4.&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="c"&gt;/* Astra */&lt;/span&gt;

&lt;span class="c"&gt;/**
 * Hide the default logo. 
 *
 * For posts, use format .postid-49272
 */&lt;/span&gt;
&lt;span class="nc"&gt;.page-id-4&lt;/span&gt; &lt;span class="nc"&gt;.custom-logo&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="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/** 
 * Let's use a different logo.
 *
 * The site link is respected.
 */&lt;/span&gt;
&lt;span class="nc"&gt;.page-id-4&lt;/span&gt; &lt;span class="nt"&gt;a&lt;/span&gt;&lt;span class="nc"&gt;.custom-logo-link.transparent-custom-logo&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;background-image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sx"&gt;url(https://balistreetphotographer.files.wordpress.com/2019/02/balistreetphotographer-logo-2-slashes-65.png)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;background-repeat&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;no-repeat&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;background-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&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="nb"&gt;block&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="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;65px&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;65px&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;h3&gt;
  
  
  The Result
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RSjvcc3Z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/v10ustab7gq1dyyus1zy.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RSjvcc3Z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/v10ustab7gq1dyyus1zy.jpg" alt="Astra - Changing the Logo for a Specific Page" title="Astra"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Different Logo for Different Pages using Twenty Twenty #
&lt;/h2&gt;

&lt;p&gt;This CSS will change the logo only for a page on an Twenty Twenty site that's ID is 14.&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="c"&gt;/* Twenty Twenty */&lt;/span&gt;

&lt;span class="c"&gt;/** 
 * Hide the default logo. 
 *
 * For posts use .postid-1 format.
 */&lt;/span&gt;
&lt;span class="nc"&gt;.page-id-14&lt;/span&gt; &lt;span class="nc"&gt;.custom-logo-link&lt;/span&gt; &lt;span class="nt"&gt;img&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="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/** 
 * Drop in a different logo.
 *
 * The site link is respected.
 */&lt;/span&gt;
&lt;span class="nc"&gt;.page-id-14&lt;/span&gt; &lt;span class="nc"&gt;.custom-logo-link&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;background-image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sx"&gt;url(https://balistreetphotographer.files.wordpress.com/2019/02/balistreetphotographer-logo-2-slashes-65.png)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;background-repeat&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;no-repeat&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;background-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&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="nb"&gt;block&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="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;65px&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;65px&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;h3&gt;
  
  
  The Result
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yNxGV4Hf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/sz3wjd7mz9hn5pwmx5xu.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yNxGV4Hf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/sz3wjd7mz9hn5pwmx5xu.jpg" alt="Twenty Twenty- Changing the Logo for a Specific Page" title="Twenty Twenty"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What About Retina? #
&lt;/h2&gt;

&lt;p&gt;With Retina, we need to check the device using &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries"&gt;CSS media queries&lt;/a&gt;. Then, we can use a higher res (2x) logo. But, we still need to contain the logo so it fits in the header. We do that by fixing the background size dimensions.&lt;/p&gt;

&lt;p&gt;Using the Avada theme as an example, you would add this extra CSS. Note the differences that I flag in the comments.&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="c"&gt;/* Media query for Retina on Avada */&lt;/span&gt;
&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="n"&gt;screen&lt;/span&gt; &lt;span class="n"&gt;and&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;min--moz-device-pixel-ratio&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="n"&gt;screen&lt;/span&gt; &lt;span class="n"&gt;and&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;-o-min-device-pixel-ratio&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;/&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="n"&gt;screen&lt;/span&gt; &lt;span class="n"&gt;and&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;-webkit-min-device-pixel-ratio&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="n"&gt;screen&lt;/span&gt; &lt;span class="n"&gt;and&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;min-device-pixel-ratio&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nc"&gt;.page-id-18&lt;/span&gt; &lt;span class="nc"&gt;.fusion-logo-link&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;background-image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sx"&gt;url(https://balistreetphotographer.files.wordpress.com/2019/02/balistreetphotographer-logo-2-black-250.png)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* High res logo */&lt;/span&gt;
    &lt;span class="nl"&gt;background-repeat&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;no-repeat&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;background-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;65px&lt;/span&gt; &lt;span class="m"&gt;65px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* Instead of 100%. New for Retina. */&lt;/span&gt;
    &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;block&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* Add !important if needed. */&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="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;65px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* Add !important if needed. */&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;65px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* Add !important if needed. */&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;h3&gt;
  
  
  The Result
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KXhI2ep8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/hpmsa3m5adboh0xlzrwv.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KXhI2ep8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/hpmsa3m5adboh0xlzrwv.jpg" alt="Retina for Avada" title="Retina for Avada"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How Do I Get the Page or Post ID? #
&lt;/h2&gt;

&lt;p&gt;Go to the page that you want to change the logo. View source. Search on &lt;code&gt;&amp;lt;body&lt;/code&gt;. Look for the page or post ID class.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--y79bPnpI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/bjex3m6m09p2170zhntm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--y79bPnpI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/bjex3m6m09p2170zhntm.png" alt="Getting the Post ID in Avada" title="Getting the Post ID in Avada"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How Do I Add Custom CSS?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://medium.com/@marklchaves/adding-custom-css-to-your-wordpress-website-how-to-guide-a50b474af36d"&gt;Adding Custom CSS to Your WordPress Site&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;As always, shout if you've got a question.&lt;/p&gt;

&lt;p&gt;See ya next time. Share &amp;amp; enjoy! &lt;/p&gt;

</description>
      <category>wordpress</category>
      <category>logo</category>
      <category>theme</category>
      <category>css</category>
    </item>
    <item>
      <title>Creating a Full-Width Hero in GeneratePress (Free Version)</title>
      <dc:creator>mark l chaves</dc:creator>
      <pubDate>Fri, 13 Mar 2020 05:56:24 +0000</pubDate>
      <link>https://forem.com/marklchaves/creating-a-full-width-hero-in-generatepress-free-version-1ki9</link>
      <guid>https://forem.com/marklchaves/creating-a-full-width-hero-in-generatepress-free-version-1ki9</guid>
      <description>&lt;p&gt;I'm in the middle of evaluating fast loading WordPress themes. Part of my due diligence is creating a typical home page in the theme I'm testing.&lt;/p&gt;

&lt;p&gt;I was excited to find out how quickly I could create a beautiful full-width homepage Hero image in GeneratePress—without any plugins or premium add-ons. So, I'm sharing. &lt;/p&gt;

&lt;p&gt;For this tutorial, we'll use the free version of the &lt;strong&gt;GeneratePress&lt;/strong&gt; theme and the &lt;strong&gt;Gutenberg&lt;/strong&gt; WordPress block editor. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;BTW, I am not affiliated with GeneratePress nor any software vendor for that matter.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  What We'll Cover
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;GeneratePress theme settings&lt;/li&gt;
&lt;li&gt;Gutenberg document settings&lt;/li&gt;
&lt;li&gt;Gutenberg block settings&lt;/li&gt;
&lt;li&gt;Extra custom CSS for &lt;em&gt;umph&lt;/em&gt;!&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you want to follow along, here's the image I used from &lt;a href="https://unsplash.com/photos/MNmYtfLvKsA"&gt;Unsplash&lt;/a&gt;. Feel free to download it, crop it to 1280x849 pixels, then optimise it to around 200 KB or less.&lt;/p&gt;




&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  GeneratePress Theme Settings #
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Header
&lt;/h3&gt;

&lt;p&gt;Navigate to &lt;strong&gt;Appearance&lt;/strong&gt; &amp;gt; &lt;strong&gt;Customize&lt;/strong&gt; &amp;gt; &lt;strong&gt;Layout&lt;/strong&gt; &amp;gt; &lt;strong&gt;Header&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Header Presets: Navigation Right&lt;/li&gt;
&lt;li&gt;Header Width: Full&lt;/li&gt;
&lt;li&gt;Inner Header Width: Full&lt;/li&gt;
&lt;li&gt;Header Alignment: Left&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---nB32LiN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/w4irzxa4f5oh2gahjh1u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---nB32LiN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/w4irzxa4f5oh2gahjh1u.png" alt="Generate Press Header Layout Settings" title="Generate Press Header Layout Settings"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Navigation
&lt;/h3&gt;

&lt;p&gt;Navigate to &lt;strong&gt;Appearance Customize&lt;/strong&gt; &amp;gt; &lt;strong&gt;Layout&lt;/strong&gt; &amp;gt; &lt;strong&gt;Primary Navigation&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Navigation Width: Full&lt;/li&gt;
&lt;li&gt;Inner Navigation Width: Contained&lt;/li&gt;
&lt;li&gt;Navigation Alignment: Left&lt;/li&gt;
&lt;li&gt;Navigation Location: Float Right&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hGoTWqW7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/b9jv853u8sk5ly53twtz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hGoTWqW7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/b9jv853u8sk5ly53twtz.png" alt="Generate Press Navigation Layout Settings" title="Generate Press Navigation Layout Settings"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Make sure you hit the "Publish" button to save your changes. Now, create a new page using Gutenberg (block editor). &lt;/p&gt;

&lt;p&gt;If you need a Gutenberg refresher, scope out this &lt;a href="https://www.shoutmeloud.com/tutorial-use-wordpress-gutenberg-editor.html"&gt;Gutenberg tutorial&lt;/a&gt; from Shout Me Loud.&lt;/p&gt;

&lt;p&gt;Alright! Let's hit the document settings.&lt;/p&gt;




&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Gutenberg Document Settings #
&lt;/h2&gt;

&lt;p&gt;Select these options for your document settings.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sidebars: Content (no sidebars)&lt;/li&gt;
&lt;li&gt;Page Builder Container: Full Width&lt;/li&gt;
&lt;li&gt;Disable Elements: Content title&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Got all that? Great. Time to create a cover block. &lt;/p&gt;

&lt;h3&gt;
  
  
  Add a Cover Block
&lt;/h3&gt;

&lt;p&gt;Add a new block at the top of the page. Select &lt;strong&gt;Cover&lt;/strong&gt; as the block type.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zenqbyZJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/z7khyg3194ohnpdyiv44.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zenqbyZJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/z7khyg3194ohnpdyiv44.png" alt="Gutenberg Cover Block"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Upload the image you prepared earlier. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FhRZF3-b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/nh196makhoivc13ecdb8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FhRZF3-b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/nh196makhoivc13ecdb8.png" alt="Gutenberg Upload Media"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, let's tweak the settings for our new cover block.&lt;/p&gt;




&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Gutenberg Block Settings #
&lt;/h2&gt;

&lt;p&gt;Select these options for your block settings.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Media Settings: Fixed background (gives us a hip &lt;a href="https://www.w3schools.com/howto/howto_css_parallax.asp"&gt;parallax effect&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Dimensions &amp;gt; Minimum height pixels: 849px (remember the height of our hero image above?)&lt;/li&gt;
&lt;li&gt;Overlay &amp;gt; Background Opacity: 50%&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Whew! We're almost there.&lt;/p&gt;




&lt;h2&gt;
  
  
  Custom CSS for Some Umph!
&lt;/h2&gt;

&lt;p&gt;Ok. So I added custom CSS to ensure the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Our top nav bar is non-sticky &lt;/li&gt;
&lt;li&gt;Our top nav bar has a transparent background&lt;/li&gt;
&lt;li&gt;Our top nav bar isn't hidden by the cover block we created&lt;/li&gt;
&lt;li&gt;Our site title pops from the dark background&lt;/li&gt;
&lt;li&gt;And finally, so that this styling is applied only to the homepage&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here's the custom CSS I used.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/* Need this to make transparent header overlay for homepage hero. */&lt;/span&gt;
&lt;span class="nc"&gt;.page-id-6&lt;/span&gt; &lt;span class="nc"&gt;.site-header&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;z-index&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2&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;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;right&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;transparent&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/* Brighten the branding text to make it pop on a dark background. */&lt;/span&gt;
&lt;span class="nc"&gt;.page-id-6&lt;/span&gt; &lt;span class="nc"&gt;.main-title&lt;/span&gt; &lt;span class="nt"&gt;a&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;whitesmoke&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;Don't know where to put this CSS? Please read &lt;a href="https://medium.com/@marklchaves/adding-custom-css-to-your-wordpress-website-how-to-guide-a50b474af36d"&gt;How to Add CSS to WordPress&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Don't know how to find the page ID? Bring up your page in a browser. View the source. Search on "&amp;lt;body".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XUtCFkvJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/lo3vb85m6vfqkucvlwsu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XUtCFkvJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/lo3vb85m6vfqkucvlwsu.png" alt="Getting the Page-ID"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Yay, you did it! High five!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DyalQn0R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/uqy9jh531rp1hkg2ilxh.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DyalQn0R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/uqy9jh531rp1hkg2ilxh.jpg" alt="Homepage Hero using Gutenberg running on the GeneratePress WordPress Theme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks for reading. Share &amp;amp; enjoy ;-)&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The hero image used is a 35mm film scan of a horse &amp;amp; buggy driver in the historic city of Yogyakarta, Indonesia.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>wordpress</category>
      <category>webdev</category>
      <category>gutenberg</category>
      <category>css</category>
    </item>
    <item>
      <title>What is Art Direction and How to Use it</title>
      <dc:creator>mark l chaves</dc:creator>
      <pubDate>Fri, 07 Feb 2020 09:23:48 +0000</pubDate>
      <link>https://forem.com/marklchaves/what-is-art-direction-and-how-to-use-it-1o3n</link>
      <guid>https://forem.com/marklchaves/what-is-art-direction-and-how-to-use-it-1o3n</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Help! My banner images are cut off on mobile.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I see messages like this a lot in &lt;a href="https://wordpress.org/search/header+image+cut+off/?forums=1" rel="noopener noreferrer"&gt;help forums&lt;/a&gt;. It usually means we have a "hero" image with an &lt;strong&gt;important&lt;/strong&gt; subject placed on the left or right side of the picture. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmarklchaves.files.wordpress.com%2F2020%2F02%2Ftest2slider-lt-768.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/https%3A%2F%2Fmarklchaves.files.wordpress.com%2F2020%2F02%2Ftest2slider-lt-768.jpg" title="Right Justified Hero Image" alt="Right Justified Hero Image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On a desktop, it looks fab. On a laptop, it looks so-so. When we get to a tablet—we're not so happy as the main subject starts to fall off the edge. On a mobile. Forget about it. The subject is gone.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F101l7sv3kns2fsjlxiwk.gif" 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/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F101l7sv3kns2fsjlxiwk.gif" alt="Opposite of Responsive Design" title="Opposite of Responsive Design"&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;
    Above is the opposite of &lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/Responsive_web_design" rel="noopener noreferrer"&gt;responsive web design&lt;/a&gt; or RWD. The image has only one-size that is suited for a large display. It's a one-size &lt;strong&gt;doesn't&lt;/strong&gt; fit all.&lt;br&gt;
  
  &lt;/p&gt;

&lt;p&gt;One solution is to pick an image where the subject in the centre.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fd1qmdf3vop2l07.cloudfront.net%2Fhoneydew-aurora.cloudvent.net%2Fcompressed%2F_min_%2F5b9567e5a14dcc2fb4deee234ba0dde4.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/https%3A%2F%2Fd1qmdf3vop2l07.cloudfront.net%2Fhoneydew-aurora.cloudvent.net%2Fcompressed%2F_min_%2F5b9567e5a14dcc2fb4deee234ba0dde4.jpg" title="35mm Film Photograph with Subject in the Centre" alt="35mm Film Photograph with Subject in the Centre"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This isn't always possible nor desired. What's the answer if you need to use a left or right justified image?&lt;/p&gt;

&lt;p&gt;The answer is to use &lt;a href="https://cloudfour.com/thinks/responsive-images-101-definitions/#artdirection" rel="noopener noreferrer"&gt;art direction&lt;/a&gt; images with &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries" rel="noopener noreferrer"&gt;CSS media queries&lt;/a&gt;. Let's do it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Art Direction Images with CSS Media Queries
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 1 Create the Images
&lt;/h3&gt;

&lt;p&gt;We need to create a set of images from the original. Each image will have a different width and height and different &lt;em&gt;compositions&lt;/em&gt; to keep the subject in view.&lt;/p&gt;

&lt;p&gt;Using the image of the woman and child as an example, here are the art direction versions we'll use.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Desktop 2000 x 768 px.&lt;/li&gt;
&lt;li&gt;Mobile landscape 600 x 768 px.&lt;/li&gt;
&lt;li&gt;Laptop 1240 x 768 px.&lt;/li&gt;
&lt;li&gt;Mobile portrait 480 x 768 px.&lt;/li&gt;
&lt;li&gt;Tablet 768 x 768 px.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F0rgoqr3varoah3gk7zjq.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/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F0rgoqr3varoah3gk7zjq.jpg" alt="Example Art Direction Images"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Question—do five different images seem extreme? We need at least five because of how close the two subjects are to the right edge. How many versions depends on the original photo composition. Sometimes two is enough.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2 Create the CSS Media Queries
&lt;/h3&gt;

&lt;p&gt;We'll need &lt;strong&gt;four&lt;/strong&gt; media queries. We want our code to default to the mobile portrait image. The default doesn’t need a media query. &lt;/p&gt;

&lt;p&gt;So we’ll write four media queries to kick-in the four larger versions as the display becomes wider. See the &lt;em&gt;breakpoints&lt;/em&gt; in the snippet below. &lt;/p&gt;

&lt;h4&gt;
  
  
  The CSS Media Queries for the Art Direction Images
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;
&lt;span class="c"&gt;/* 
 * || Responsive Web Design Demo (formerly using Fusion Slider)
 *
 * mark l chaves 24 July 2019 (updated 9 September 2019)
 */&lt;/span&gt;

&lt;span class="c"&gt;/* Mobile first responsive web design. */&lt;/span&gt;
&lt;span class="nc"&gt;.hero&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;background-image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sx"&gt;url(https://marklchaves.files.wordpress.com/2020/02/test2slider-mob-768.jpg)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;background-repeat&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;no-repeat&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;background-position&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;background-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;cover&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/* Mobile landscape breakpoint. */&lt;/span&gt;
&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="n"&gt;only&lt;/span&gt; &lt;span class="n"&gt;screen&lt;/span&gt; &lt;span class="n"&gt;and&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;min-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;480px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;.hero&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;background-image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sx"&gt;url(https://marklchaves.files.wordpress.com/2020/02/test2slider-land-768.jpg)&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;span class="c"&gt;/* Tablet breakpoint. */&lt;/span&gt;
&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="n"&gt;only&lt;/span&gt; &lt;span class="n"&gt;screen&lt;/span&gt; &lt;span class="n"&gt;and&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;min-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;768px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;.hero&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;background-image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sx"&gt;url(https://marklchaves.files.wordpress.com/2020/02/test2slider-tab-768.jpg)&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;span class="c"&gt;/* Laptop breakpoint. */&lt;/span&gt;
&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="n"&gt;only&lt;/span&gt; &lt;span class="n"&gt;screen&lt;/span&gt; &lt;span class="n"&gt;and&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;min-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1024px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;.hero&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;background-image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sx"&gt;url(https://marklchaves.files.wordpress.com/2020/02/test2slider-lt-768.jpg)&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;span class="c"&gt;/* Desktop breakpoint. */&lt;/span&gt;
&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="n"&gt;only&lt;/span&gt; &lt;span class="n"&gt;screen&lt;/span&gt; &lt;span class="n"&gt;and&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;min-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1600px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;.hero&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;background-image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sx"&gt;url(https://marklchaves.files.wordpress.com/2020/02/test2slider-dt-768.jpg)&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;h3&gt;
  
  
  Step 3 Test the Result
&lt;/h3&gt;

&lt;p&gt;Here's what you should see.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/TfFGc2amScfP8TOTYb/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/TfFGc2amScfP8TOTYb/giphy.gif" alt="Using Art Direction for Responsive Design" title="Using Art Direction for Responsive Design"&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;
    Putting it all together. Our responsive web design using art direction.&lt;br&gt;
  
  &lt;/p&gt;

&lt;h4&gt;
  
  
  Live Demo on Codepen
&lt;/h4&gt;

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

&lt;p&gt;Note: Please log in to your CodePen account to view if the pen doesn't show up at first.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;I hope you learned something new! At the very least, you'll know how to help someone when their &lt;em&gt;heroes&lt;/em&gt; are cut off on mobile devices ;-)&lt;/p&gt;

&lt;p&gt;Learn more about &lt;a href="https://usecases.responsiveimages.org/#art-direction" rel="noopener noreferrer"&gt;art direction and responsive design&lt;/a&gt; at the W3C.&lt;/p&gt;

&lt;p&gt;Shout if you have any questions.&lt;/p&gt;




&lt;p&gt;35mm Film Photograph of a &lt;a href="https://unsplash.com/photos/XtpUeE12Iq4" rel="noopener noreferrer"&gt;Balinese Man on Unsplash&lt;/a&gt; by mark l chaves.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>css</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Fixing the Equal Height Columns Problem (CSS)</title>
      <dc:creator>mark l chaves</dc:creator>
      <pubDate>Tue, 14 Jan 2020 10:08:19 +0000</pubDate>
      <link>https://forem.com/marklchaves/fixing-the-equal-height-columns-problem-css-m7o</link>
      <guid>https://forem.com/marklchaves/fixing-the-equal-height-columns-problem-css-m7o</guid>
      <description>&lt;h2&gt;
  
  
  Overview
&lt;/h2&gt;

&lt;p&gt;The equal height columns problem (or &lt;a href="https://en.wikipedia.org/wiki/Anti-pattern" rel="noopener noreferrer"&gt;anti-pattern&lt;/a&gt;) is where we have 2-3 three columns in one row. Each column has a different amount of content. So, the bottom of the columns don’t line up evenly. &lt;/p&gt;

&lt;p&gt;Ideally on a larger display, we want to have each column be the same height. And, we want to have buttons or links at bottom of each column be lined-up at the same level/height across the columns.&lt;/p&gt;

&lt;p&gt;Here's the anti-pattern we are getting now.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fsd92rt23nr8xz2w0z9ds.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/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fsd92rt23nr8xz2w0z9ds.jpg" title="Equal Height Columns Problem (Before)" alt="Equal Height Columns Problem (Before)"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;equal height&lt;/em&gt; challenge is not specific to just one WordPress theme. But, I'll be using the Avada WordPress theme (no affiliation) for the code examples. &lt;/p&gt;

&lt;p&gt;More importantly, if you can master this common web design pattern here, you’ll be able to handle it like a pro in other themes (or static sites).&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Goals [#]
&lt;/h2&gt;

&lt;p&gt;Let's recap our goals. On a laptop and desktop view:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;We would love to have the content boxes be equal height.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Say we have three columns with text and a CTA button in each column. The three CTA buttons will hug the bottom of the text block elements (not the bottom of the equal height columns). This means, the positioning of these buttons are at different heights. I.e, &lt;strong&gt;not&lt;/strong&gt; what we want. Instead, We &lt;strong&gt;want&lt;/strong&gt; them to all line up evenly across the bottom.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We don’t want to be forced to always use the exact amount of text for our content boxes like the Avada demos do. The Avada ThemeFusion demos give the illusion of equal height content boxes in a row. They do this by ensuring all the text in their content boxes have the same amount of characters.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F4mvtq3azhj0zkd7zgsl7.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/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F4mvtq3azhj0zkd7zgsl7.jpg" title="Equal Heights Illusion - Theme Demos Using Equal Text to Simulate Equal Heights" alt="Avada Theme Demo Simulating Equal Height Columns"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Above: The Equal Heights Illusion - Avada Theme Demos Using Equal Text to Simulate Equal Heights&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Our solution should look something like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Ff2l6lr9rwqt5kb8zlml4.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/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Ff2l6lr9rwqt5kb8zlml4.jpg" title="Equal Heights Problem Solved" alt="Equal Heights Problem Solved"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Side by Side Before/After
&lt;/h3&gt;

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

&lt;p&gt;Note: Please log in to your CodePen account to view if the pen doesn't show up at first.&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Our First Two Attempts [#]
&lt;/h2&gt;

&lt;p&gt;If we didn't know anything about the equal height columns anti-pattern, we naively would try these two approaches:&lt;/p&gt;
&lt;h3&gt;
  
  
  First Try - One Row and One Column of Content Boxes
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Create one row with one column.&lt;/li&gt;
&lt;li&gt;Inside the &lt;strong&gt;one&lt;/strong&gt; column, add a Content Boxes Element.&lt;/li&gt;
&lt;li&gt;Create three items inside the Content Boxes Element.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fbecalii9sbjtqkbfvtf9.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/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fbecalii9sbjtqkbfvtf9.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Above: One Wide Column (yellow) with One Content Boxes Element that has Three Items (green)&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Second Try - One Row with Three Columns with One Content Box Each
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Create one row.&lt;/li&gt;
&lt;li&gt;Enable the Set Columns to Equal Height setting for the row.&lt;/li&gt;
&lt;li&gt;Create three columns (1/3 width each).&lt;/li&gt;
&lt;li&gt;In each 1/3 column, create one Content Boxes Element.&lt;/li&gt;
&lt;li&gt;Create one item in each of the Content Boxes Element.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F6w0fwrlol6hn617ucsrg.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/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F6w0fwrlol6hn617ucsrg.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Above: Three Columns (yellow) with Three Content Boxes (green)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;As you've probably have noticed, neither approach works.&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Solution [#]
&lt;/h2&gt;

&lt;p&gt;What’s the solution? One solution involves using the First Try method (above) and writing custom CSS to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Perform a media query (responsive design).&lt;/li&gt;
&lt;li&gt;Set a fixed height for the content boxes.&lt;/li&gt;
&lt;li&gt;Push the buttons down to the bottom using absolute positioning.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I know you are wondering. How many lines of code will this cost me? Six!&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;

&lt;span class="c"&gt;/* Only do this fancy stuff for devices larger than a tablet. */&lt;/span&gt;
&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="n"&gt;only&lt;/span&gt; &lt;span class="n"&gt;screen&lt;/span&gt; &lt;span class="n"&gt;and&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;min-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1025px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nc"&gt;.content-container&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;min-height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;500px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* Change this to what you need. */&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="c"&gt;/* Ground the CTA button. */&lt;/span&gt;
  &lt;span class="nc"&gt;.fusion-button-wrapper&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;bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5px&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;h3&gt;
  
  
  Instructions
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Add this CSS code to your &lt;a href="https://medium.com/@marklchaves/adding-custom-css-to-your-wordpress-website-how-to-guide-a50b474af36d" rel="noopener noreferrer"&gt;Custom CSS code editor&lt;/a&gt; for the page that has your content boxes.&lt;/li&gt;
&lt;li&gt;Adjust the &lt;code&gt;min-height&lt;/code&gt; value to what works for you.&lt;/li&gt;
&lt;li&gt;Click Update to save the page.&lt;/li&gt;
&lt;li&gt;Reload the page (clear caches if needed) to view the changes.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  Recap of the Code
&lt;/h3&gt;

&lt;p&gt;OK. Here's what this CSS is doing.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A media query to force equal heights only for larger devices. For anything smaller than &lt;code&gt;1025px&lt;/code&gt;, the design becomes responsive by stacking the content boxes.&lt;/li&gt;
&lt;li&gt;A &lt;code&gt;min-height&lt;/code&gt; property for the content boxes to ensure each box has the same height inside their &lt;em&gt;parent&lt;/em&gt; containers.&lt;/li&gt;
&lt;li&gt;Absolute positioning on the button components to force them to the bottom of their container columns.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Flex Version [#]
&lt;/h3&gt;

&lt;p&gt;What's that you say? Where's the CSS3 flexbox version?!&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;

&lt;span class="c"&gt;/* Only do this fancy stuff for devices larger than a tablet. */&lt;/span&gt;
&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="n"&gt;only&lt;/span&gt; &lt;span class="n"&gt;screen&lt;/span&gt; &lt;span class="n"&gt;and&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;min-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1025px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nc"&gt;.content-container&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;flex&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;flex-flow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;column&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt; &lt;span class="m"&gt;200px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;min-height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;450px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* Change this to what you need. */&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="c"&gt;/* Need to force the width for the paragraph for some reason. */&lt;/span&gt;
  &lt;span class="nc"&gt;.content-container&lt;/span&gt; &lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;min-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;300px&lt;/span&gt; &lt;span class="cp"&gt;!important&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="c"&gt;/* Ground the CTA button. */&lt;/span&gt;
  &lt;span class="nc"&gt;.fusion-button-wrapper&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt; &lt;span class="m"&gt;100px&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;flex&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;align-items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;flex-end&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* Ground the button . */&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;left&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* left | center | right */&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;h4&gt;
  
  
  Vanilla Flexbox Example on CodePen
&lt;/h4&gt;

&lt;p&gt;This solution is more elegant than the Avada one above. Instead of worrying so much about the button, I use &lt;code&gt;flex: 1&lt;/code&gt; for the middle content section. With that 1-line of CSS, the positioning of the button towards the bottom comes for free.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;flex: 1&lt;/code&gt; is shorthand for flex-grow of a factor of 1. I.e., take up all the &lt;em&gt;remaining&lt;/em&gt; space by 1 factor.&lt;/p&gt;

&lt;p&gt;Thanks to Angus for sharing this technique with me! :-)&lt;/p&gt;

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

&lt;p&gt;Note: Please log in to your CodePen account to view if the pen doesn't show up at first.&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Recognise the Anti-pattern [#]
&lt;/h2&gt;

&lt;p&gt;I've seen the equal height columns issue come up enough times—hence this post. Learn to recognise the &lt;strong&gt;anti-pattern&lt;/strong&gt;. Then, you can be a &lt;em&gt;rock star&lt;/em&gt; by applying the &lt;strong&gt;design patterns&lt;/strong&gt; I've shared above.&lt;/p&gt;

&lt;p&gt;Share &amp;amp; enjoy!&lt;/p&gt;

</description>
      <category>css</category>
      <category>webdev</category>
      <category>wordpress</category>
      <category>antipattern</category>
    </item>
    <item>
      <title>Slow Page Refreshes Getting you Down? 3 Free Ways to Turbocharge your Dev Workflow with Browser Syncing</title>
      <dc:creator>mark l chaves</dc:creator>
      <pubDate>Wed, 25 Dec 2019 15:21:25 +0000</pubDate>
      <link>https://forem.com/marklchaves/slow-page-refreshes-getting-you-down-three-free-ways-to-supercharge-your-development-workflow-with-browser-syncing-266i</link>
      <guid>https://forem.com/marklchaves/slow-page-refreshes-getting-you-down-three-free-ways-to-supercharge-your-development-workflow-with-browser-syncing-266i</guid>
      <description>&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Method 1 - Static Sites [#]
&lt;/h2&gt;

&lt;p&gt;For straight up HTML, CSS, and JavaScript, I use &lt;strong&gt;Visual Studio (VS) Code&lt;/strong&gt; with the &lt;em&gt;Live Server&lt;/em&gt; extension by &lt;a href="https://github.com/ritwickdey"&gt;Ritwick Dey&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Install the &lt;em&gt;Live Server&lt;/em&gt; extension. Bring up your VS Code workspace. Right click on your &lt;code&gt;index.html&lt;/code&gt; (or any HTML file). Select "Open with Live Server." Pretty easy.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--89ZhEDP9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://raw.githubusercontent.com/ritwickdey/vscode-live-server/master/images/Screenshot/vscode-live-server-explorer-menu-demo-1.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--89ZhEDP9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://raw.githubusercontent.com/ritwickdey/vscode-live-server/master/images/Screenshot/vscode-live-server-explorer-menu-demo-1.gif" alt="Live Demo Gif of Live Server" title="Gif courtesy of the _Live Server_ extension page."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Method 2 - Jekyll [#]
&lt;/h2&gt;

&lt;p&gt;Since December 2017 with Jekyll 3.7, you can run &lt;code&gt;jekyll serve&lt;/code&gt; with the &lt;code&gt;livereaload&lt;/code&gt; switch. It's that easy.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;bundle exec jekyll serve --livereload&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;Done!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mwqXHgg8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/jh0r7xkcfu5zazmznyi6.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mwqXHgg8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/jh0r7xkcfu5zazmznyi6.gif" alt="Jekyll Live Reload Demo" title="Jekyll Live Reload Demo"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Method 3 - WordPress [#]
&lt;/h2&gt;

&lt;p&gt;No lie. It's going to take a bit more work to set up a live browser refresh with WordPress. Btw, I'm running Local by Flywheel (no affiliation).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ngc9Rl7_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/pg287l3nv6jh1156nwn7.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ngc9Rl7_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/pg287l3nv6jh1156nwn7.gif" alt="Trigger Browsersync Demo" title="Trigger Browsersync Demo"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Two Main Requirements
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Reload the browser on PHP and CSS file changes (we'll use Browsersync and Gulp for this)&lt;/li&gt;
&lt;li&gt;Reload the browser when posts and pages are updated (we'll use Browsersync and the &lt;em&gt;Trigger Browsersync plugin&lt;/em&gt; to handle this)&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  Browsersync
&lt;/h4&gt;

&lt;p&gt;The &lt;strong&gt;critical&lt;/strong&gt; tool for making all this magic happen is something called &lt;a href="https://www.browsersync.io/"&gt;Browsersync&lt;/a&gt;. Browsersync's tag line is,&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Time-saving synchronised browser testing.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I suspect this "testing tool" &lt;em&gt;product positioning&lt;/em&gt; is the reason it was difficult for me to discover Browsersync. Just thinking out loud here. Maybe their SEO/SEM team should consider adding these keyword phrases.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Real time page loads&lt;/li&gt;
&lt;li&gt;Real time page refreshes&lt;/li&gt;
&lt;li&gt;Automatic page refresh&lt;/li&gt;
&lt;li&gt;Automated development workflow&lt;/li&gt;
&lt;li&gt;Live view&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;But, I digress. The main thing to remember is that WordPress is a dynamic site generator. That means we need to configure Browsersync to deal with this. We'll use Browsersync to run a proxy server for our dev site to handle the page refreshes.&lt;/p&gt;

&lt;h4&gt;
  
  
  Gulp - Watching our PHP and CSS Files
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://gulpjs.com/"&gt;Gulp&lt;/a&gt; is a task runner. I've read that Gulp's architecture makes &lt;a href="https://www.keycdn.com/blog/gulp-vs-grunt"&gt;Gulp a faster alternative to Grunt&lt;/a&gt; (a Gulp competitor).&lt;/p&gt;

&lt;h3&gt;
  
  
  Here's my Gulp File
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;gulp&lt;/span&gt;        &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;gulp&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;browserSync&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;browser-sync&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;create&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;reload&lt;/span&gt;      &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;browserSync&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;reload&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;gulp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;task&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;serve&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Standard call for dynamic sites.&lt;/span&gt;
    &lt;span class="nx"&gt;browserSync&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;init&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
        &lt;span class="na"&gt;proxy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;avada.local&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;

    &lt;span class="c1"&gt;// Watch PHP and CSS files.&lt;/span&gt;
    &lt;span class="nx"&gt;gulp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;watch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;**/*.php&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;change&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;reload&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;gulp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;watch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;**/*.css&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;change&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;reload&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="cm"&gt;/**
 * Place this file in "Local Sites/YOURSITENAMEHERE"
 * Usage: gulp serve
 */&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  Trigger Browsersync WordPress Plugin - Watching our Pages &amp;amp; Posts Updates
&lt;/h4&gt;

&lt;p&gt;Thank goodness we have the &lt;a href="https://wordpress.org/plugins/trigger-browsersync/"&gt;Trigger Browsersync WordPress plugin by Sami Greenbury&lt;/a&gt;. And, I love the way it piggy backs onto Browsersync (loose coupling).&lt;/p&gt;

&lt;p&gt;You will need to follow the install instructions carefully. I did find a &lt;a href="https://wordpress.org/support/topic/undefined-variable-emssage/"&gt;teeny bug&lt;/a&gt; (typo) that can be easily fixed. If you run into it too, then change "emssage" to "message" on line 275 in the &lt;code&gt;trigger-browsersync.php&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;If you have any issues at all with the set up, I highly recommend turning on your PHP debugging and telling the Trigger Browsersync plugin to log events via a filter. See my snippet of the special &lt;code&gt;mu-plugins/enable-trigger-browsersync.php&lt;/code&gt; file below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class="nx"&gt;add_action&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="s1"&gt;'plugins_loaded'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt; &lt;span class="c1"&gt;// Trigger after the TriggerBrowsersync pluginhas loaded&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nb"&gt;class_exists&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="s1"&gt;'TriggerBrowsersync'&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;span class="c1"&gt;// Check the TriggerBrowsersync plugin loaded correctly&lt;/span&gt;
        &lt;span class="c1"&gt;// Add any configuration filters you may need here.&lt;/span&gt;

        &lt;span class="c1"&gt;// I'm going to turn on logging.&lt;/span&gt;
        &lt;span class="nx"&gt;add_filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'trigger_browsersync_log_events'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'__return_true'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;// Activate the integration by creating an instance.&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;TriggerBrowsersync&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;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Need to read up on &lt;code&gt;mu-plugins&lt;/code&gt;? &lt;a href="https://wordpress.org/support/article/must-use-plugins/"&gt;Check the Codex&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion [#]
&lt;/h2&gt;

&lt;p&gt;It's super easy and a &lt;em&gt;no brainer&lt;/em&gt; to whip up a real time feed of your dev edits if you are using 1) VS Code for your static sites or 2) Jekyll for your SSG sites.&lt;/p&gt;

&lt;p&gt;As you probably noticed, getting a live browser sync working in your WordPress dev environment is the most challenging of the three methods described. The good/great news is—it can be done! Which makes it worthwhile IMHO.&lt;/p&gt;

&lt;p&gt;Another huge bonus is that all the tech mentioned in this article are absolutely &lt;strong&gt;free&lt;/strong&gt;. Please remember to support your developers.&lt;/p&gt;

&lt;p&gt;Lastly, be sure you are comfortable with Browsersync and Gulp if you attempt the WordPress method described above.&lt;/p&gt;

&lt;p&gt;Give me a shout if you have any questions. Good luck and happy coding (sans manual page refreshes)!&lt;/p&gt;

</description>
      <category>wordpress</category>
      <category>webdev</category>
      <category>vscode</category>
      <category>productivity</category>
    </item>
    <item>
      <title>The Staggered Layout Problem (Mobile Stacking Order)</title>
      <dc:creator>mark l chaves</dc:creator>
      <pubDate>Mon, 02 Dec 2019 08:58:19 +0000</pubDate>
      <link>https://forem.com/marklchaves/the-staggered-layout-problem-mobile-stacking-order-3gnp</link>
      <guid>https://forem.com/marklchaves/the-staggered-layout-problem-mobile-stacking-order-3gnp</guid>
      <description>&lt;h2&gt;
  
  
  The Staggered Layout
&lt;/h2&gt;

&lt;p&gt;Chances are you have seen the pervasive &lt;em&gt;staggered layout&lt;/em&gt; (a.k.a., zigzag) at least once. Maybe you even use it on your own site or a site you've built for someone else.&lt;/p&gt;

&lt;p&gt;Let's take a 2x2 example—two rows two columns:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The first row has an image on the left and its text content on the right.&lt;/li&gt;
&lt;li&gt;The second row has text on the left and its image on the right.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NGsycgIR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/fgd45im023twpgp933yp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NGsycgIR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/fgd45im023twpgp933yp.png" alt="Staggered Layout Design on Laptop or Desktop" title="Staggered Layout Design on Laptop or Desktop"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Alternating images and text look nice. It breaks up &lt;em&gt;slabs&lt;/em&gt; of words. This design makes content more digestible and appealing. Until you view it on a phone.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Stacking Order Problem for Mobile Displays
&lt;/h3&gt;

&lt;p&gt;Instead of neatly stacking: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;First row image.&lt;/li&gt;
&lt;li&gt;First row text.&lt;/li&gt;
&lt;li&gt;Second row image.&lt;/li&gt;
&lt;li&gt;Second row text.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;as one expects, we get this image/text &lt;em&gt;sandwich&lt;/em&gt; (&lt;a href="https://en.wikipedia.org/wiki/Anti-pattern"&gt;anti-pattern&lt;/a&gt;) thingie:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;First row image.&lt;/li&gt;
&lt;li&gt;First row text.&lt;/li&gt;
&lt;li&gt;Second row text.&lt;/li&gt;
&lt;li&gt;Second row image.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here's a visual of what I mean. Again, this gif demos what we &lt;em&gt;don't&lt;/em&gt; want.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dGVAL2mE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/5jomxfwewa1sx1lpplmh.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dGVAL2mE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/5jomxfwewa1sx1lpplmh.gif" alt="Image Text Text Image Stacking Order"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Just to Summarise
&lt;/h3&gt;

&lt;p&gt;The gif shows us what we &lt;strong&gt;don't&lt;/strong&gt; want: image &amp;gt; text &amp;gt; text &amp;gt; image.&lt;/p&gt;

&lt;p&gt;What we &lt;strong&gt;do&lt;/strong&gt; want is image &amp;gt; text &amp;gt; image &amp;gt; text.&lt;/p&gt;

&lt;h2&gt;
  
  
  One Attempt (Duplicating Content)
&lt;/h2&gt;

&lt;p&gt;One way to solve this &lt;em&gt;sandwich&lt;/em&gt; problem (in WordPress) is to make a copy of the second (alternating) row. Next, switch the columns in the new copy (image on the left—text on the right like the first row). Then for mobile widths, use WordPress theme visibility settings to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Hide the desktop version of the alternating row. This is the staggered version. &lt;/li&gt;
&lt;li&gt;Display the alternating row where we reversed columns. This is the extra stacked copy we created. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This definitely achieves our goal to have &lt;em&gt;image &amp;gt; text &amp;gt; image &amp;gt; text&lt;/em&gt; stacking on a mobile.&lt;/p&gt;

&lt;p&gt;You probably noticed—it's a bit of a &lt;em&gt;hack&lt;/em&gt;. And, it creates &lt;strong&gt;confusion&lt;/strong&gt; and duplicate content which means &lt;strong&gt;duplicate work&lt;/strong&gt;. This is not so much an &lt;a href="https://medium.com/@marklchaves/stop-freaking-out-over-duplicate-content-7110165236f"&gt;SEO issue&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The alternative solutions I see out there use CSS &lt;strong&gt;grid&lt;/strong&gt; or &lt;strong&gt;flexbox&lt;/strong&gt; to control display order on mobile devices. Way cool! I think. Why do they fix the mobile display second as an &lt;em&gt;after thought&lt;/em&gt;?&lt;/p&gt;

&lt;h3&gt;
  
  
  A Little Ditty on Mobile First
&lt;/h3&gt;

&lt;p&gt;Ok—hang on. I'd like to do one better. I want to make our solution &lt;strong&gt;mobile-first&lt;/strong&gt;. Meaning, let's order things for the mobile display first, then rearrange things for wider displays. Not the other way around like the other solutions. This is a subtle yet important way of thinking.&lt;/p&gt;

&lt;p&gt;Let's go!&lt;/p&gt;

&lt;h2&gt;
  
  
  The Solution (Vanilla, Gutenberg, Avada, Divi)
&lt;/h2&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Vanilla HTML and CSS [#]
&lt;/h3&gt;

&lt;p&gt;Vanilla HTML and CSS means it's agnostic. I.e., no dependencies on CMSs (CloudCannon, WordPress, Squarespace, Wix) or JavaScript libraries. This particular solution use CSS &lt;strong&gt;grid&lt;/strong&gt;. It's a fully working demo that shows the before/after. Please pay close attention to how I reverse the order in this snippet.&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="c"&gt;/** 
 * Mobile First - The images are placed above the text by
 * default. 
 *
 * Only Re-order Columns for Larger Displays
 *
 * These two lines of code is where the rubber meets the road.
 * This only affects the second row where we will put the text
 * on the left and the image on the right.
 */&lt;/span&gt;
&lt;span class="nf"&gt;#section-h&lt;/span&gt;&lt;span class="nc"&gt;.grid&lt;/span&gt; &lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="nd"&gt;:nth-of-type&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="err"&gt;1&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;order&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* This is the image. Make it go to the right. */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nf"&gt;#section-h&lt;/span&gt;&lt;span class="nc"&gt;.grid&lt;/span&gt; &lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="nd"&gt;:nth-of-type&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="err"&gt;2&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;order&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* This is the text. Make it go to the left. */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Here's the CodePen.&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;Note: Please log in to your CodePen account to view if the pen doesn't show up at first.&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Gutenberg Block Editor [#]
&lt;/h3&gt;

&lt;p&gt;Interjecting commentary: I admit. I was naive to assume Gutenberg had a nice built-in solution. Why doesn't it? It's the "new kid/latecomer" to the block (oops—no pun intended). Gutenberg has the advantage of looking at the weaknesses of all the other page builders. Oh well.&lt;/p&gt;

&lt;p&gt;Let's take-on "The 'Berg".&lt;/p&gt;

&lt;h4&gt;
  
  
  Here's our &lt;em&gt;Staggered&lt;/em&gt; Design in Gutenberg on a Large Display
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--J0aQ62zD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/swsmlxmgyeeq5nj34zgo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--J0aQ62zD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/swsmlxmgyeeq5nj34zgo.png" alt="Staggered Design using Gutenberg DT View"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Here's the Before/After on a Mobile
&lt;/h4&gt;

&lt;p&gt;Grab the handle and slide right and left to see the before (sandwich) and after (no sandwich).&lt;/p&gt;

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

&lt;h4&gt;
  
  
  Here's the CSS
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/** 
 * Fix the Staggered Problem for Mobile Stacking Order 
 *
 * This is a mobile-first approach.
 */&lt;/span&gt;
&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="n"&gt;all&lt;/span&gt; &lt;span class="n"&gt;and&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;min-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;767px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nc"&gt;.reverse-row&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;flex&lt;/span&gt; &lt;span class="cp"&gt;!important&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;flex-flow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;wrap&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;flex-direction&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;row-reverse&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;h4&gt;
  
  
  Here's Where I Added the CSS
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--O6aa_IFt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/1hsygjv2minr5htgqri8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--O6aa_IFt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/1hsygjv2minr5htgqri8.png" alt="Add CSS to Appearance &amp;gt; Customize &amp;gt; Additional CSS"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Here's Where to Hook the CSS Into the Alternating Second Row
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JHCHRw5d--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/jfa53rq02ippf6s9zxxg.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JHCHRw5d--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/jfa53rq02ippf6s9zxxg.jpg" alt="Applying the Custom CSS Class in Gutenberg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/@marklchaves/adding-custom-css-to-your-wordpress-website-how-to-guide-a50b474af36d"&gt;How to add CSS to WordPress.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Avada WordPress Theme [#]
&lt;/h3&gt;

&lt;p&gt;Besides the &lt;em&gt;obvious&lt;/em&gt; Fusion Builder classes, the CSS I used for my Avada solution is almost identical to the Gutenberg code. The main difference? I used an &lt;em&gt;ID&lt;/em&gt; instead to specifically target the second (alternating) row.&lt;/p&gt;

&lt;h4&gt;
  
  
  CSS Used for Avada
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/** 
 * Fix the Staggered Problem for Mobile Stacking Order 
 *
 * This is a mobile-first approach.
 */&lt;/span&gt;
&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="n"&gt;all&lt;/span&gt; &lt;span class="n"&gt;and&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;min-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;767px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;#reverse-cols1&lt;/span&gt; &lt;span class="nc"&gt;.fusion-builder-row.fusion-row&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;flex&lt;/span&gt; &lt;span class="cp"&gt;!important&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;flex-flow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;wrap&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;flex-direction&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;row-reverse&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;h4&gt;
  
  
  Here's the Full Avada Solution on GitHub (with Screen Grabs)
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://gist.github.com/marklchaves/aadd94aa13bd7e753031b4d54e948669"&gt;Avada Solution&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Divi WordPress Theme [#]
&lt;/h3&gt;

&lt;p&gt;Last but not least. Below is an article I used to help me start solving the &lt;em&gt;stacking order&lt;/em&gt; problem &lt;em&gt;sans&lt;/em&gt; duplicate content. &lt;a href="https://jasonchampagne.com/"&gt;Jason Champagne&lt;/a&gt; shows how to solve the stacking &lt;em&gt;sandwich&lt;/em&gt; problem both ways—with duplicate blocks and without (pure CSS).&lt;/p&gt;

&lt;p&gt;I &lt;em&gt;love&lt;/em&gt; this article. It's well worth the read even if you aren't using Divi. Bookmark it!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.elegantthemes.com/blog/divi-resources/how-to-change-divis-column-stacking-order-on-mobile-devices"&gt;Divi Solution—See Option 2&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Leave me a comment if you have any questions.&lt;/p&gt;

&lt;p&gt;Share &amp;amp; enjoy!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YmmSAzdb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://marklchaves.files.wordpress.com/2020/01/mlc-site-icon-bw-57w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YmmSAzdb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://marklchaves.files.wordpress.com/2020/01/mlc-site-icon-bw-57w.png" alt="mark l chaves freelance photographer writer web developer bali" title="mark l chaves"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>css</category>
      <category>html</category>
      <category>antipattern</category>
    </item>
    <item>
      <title>2 Pragmatic CSS Animations You can do Right Now</title>
      <dc:creator>mark l chaves</dc:creator>
      <pubDate>Mon, 25 Nov 2019 22:33:02 +0000</pubDate>
      <link>https://forem.com/marklchaves/two-pragmatic-css-animations-you-can-do-right-now-15mm</link>
      <guid>https://forem.com/marklchaves/two-pragmatic-css-animations-you-can-do-right-now-15mm</guid>
      <description>&lt;h2&gt;
  
  
  Intro
&lt;/h2&gt;

&lt;p&gt;This is a quick how-to for creating two practical CSS animations.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Fade In&lt;/li&gt;
&lt;li&gt;Slide Up&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;TL;DR show me the code&lt;/p&gt;

&lt;h2&gt;
  
  
  Motivation
&lt;/h2&gt;

&lt;p&gt;There's a story of why I'm writing this &lt;em&gt;minimalist&lt;/em&gt; how-to. I'm right in the middle of migrating my &lt;a href="https://medium.com/@marklchaves/cloudcannon-versus-wordpress-e0ff63fdb4c0"&gt;WordPress site to CloudCannon&lt;/a&gt;. That means I'm back to writing code instead of clicking lots of buttons and waiting for slow page refreshes. Yes, that's a good thing. &lt;/p&gt;

&lt;p&gt;Anyway, I wanted to give my CloudCannon site some dynamic "umph". I wanted to use similar &lt;strong&gt;animations&lt;/strong&gt; that my WordPress theme provides via button clicks—such as a simple &lt;em&gt;fade in&lt;/em&gt; and &lt;em&gt;slide up&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;So, I needed to find the CSS code to do that. I went to my "usual suspects".&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;CSS-Tricks&lt;/li&gt;
&lt;li&gt;CodePen&lt;/li&gt;
&lt;li&gt;MDN&lt;/li&gt;
&lt;li&gt;W3Schools&lt;/li&gt;
&lt;li&gt;And even here on DEV&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;del&gt;Surprisingly&lt;/del&gt; Astonishingly, almost everything that came up was overkill—not practical. Needless to say, I didn't find one live demo of CSS code to do a &lt;em&gt;fade in&lt;/em&gt; or a &lt;em&gt;slide up&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;No problem. Let's write some code.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Code &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Here's all I needed! This is freely available on &lt;strong&gt;CodePen&lt;/strong&gt;. "Knock yourself out!"&lt;/p&gt;

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

&lt;p&gt;Note: Please log in to your CodePen account to view if the pen doesn't show up at first.&lt;/p&gt;

&lt;h2&gt;
  
  
  1) Subtle Fade In
&lt;/h2&gt;

&lt;p&gt;Here's the CSS (sans fancy styling) and HTML for the first &lt;em&gt;fade-in&lt;/em&gt; from the CodePen above.&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="c"&gt;/* CSS */&lt;/span&gt;

&lt;span class="c"&gt;/* Fade in Once for Three Seconds */&lt;/span&gt;
&lt;span class="nc"&gt;.fade-in-1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;animation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;3s&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt; &lt;span class="n"&gt;fadeIn&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* Do the Fade. */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/* The fading in part. Reused above. */&lt;/span&gt;
&lt;span class="k"&gt;@keyframes&lt;/span&gt; &lt;span class="n"&gt;fadeIn&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nt"&gt;from&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&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="nt"&gt;to&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&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;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- HTML --&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;h3&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"fade-in-1"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Fade in Once for Three Seconds&lt;span class="nt"&gt;&amp;lt;/h3&amp;gt;&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The second &lt;em&gt;fade in&lt;/em&gt; might be over the top. I added it for kicks to show that you can specify how many times to play the animation. &lt;/p&gt;

&lt;p&gt;You can even let it run forever. But, let's not over do it.&lt;/p&gt;

&lt;h2&gt;
  
  
  2) Slide Up
&lt;/h2&gt;

&lt;p&gt;There's more CSS here. Again, the CSS and HTML are stripped down—no fancy highlighting or alignment.&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="c"&gt;/* CSS */&lt;/span&gt;

&lt;span class="c"&gt;/* Slide up Ease in Once for Three Seconds with Two Second Delay */&lt;/span&gt;
&lt;span class="nc"&gt;.slide-up-1-ease&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* Be invisible first. */&lt;/span&gt;
  &lt;span class="nl"&gt;animation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;3s&lt;/span&gt; &lt;span class="n"&gt;ease-in&lt;/span&gt; &lt;span class="m"&gt;2s&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt; &lt;span class="n"&gt;slideUp&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* Do the Slide. */&lt;/span&gt;
  &lt;span class="c"&gt;/* This ensures that the item to be animated 
     is hidden at the beginning, then stays
     visible at the end (persists).*/&lt;/span&gt;
  &lt;span class="nl"&gt;animation-fill-mode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;forwards&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/* The sliding up part. Reused above. */&lt;/span&gt;
&lt;span class="k"&gt;@keyframes&lt;/span&gt; &lt;span class="n"&gt;slideUp&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;0&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;0px&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;25px&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;span class="err"&gt;100&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;1&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;0px&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0px&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;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- HTML --&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;h3&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"slide-up-1-ease"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Slide up Ease in Once for Three Seconds with Two Second Delay&lt;span class="nt"&gt;&amp;lt;/h3&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  In the Wild
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://caughtmyeye.dev/photography/people/"&gt;Subtle heading (h1) fade in&lt;/a&gt; on my People portfolio page.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;p&gt;CSS Animations on &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Animations/Using_CSS_animations"&gt;The Mozilla Developer Network (MDN)&lt;/a&gt;&lt;/p&gt;

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