{"id":1924,"date":"2015-07-31T13:13:09","date_gmt":"2015-07-31T13:13:09","guid":{"rendered":"http:\/\/freshinbox.com\/blog\/?p=1924"},"modified":"2015-12-01T00:33:51","modified_gmt":"2015-12-01T00:33:51","slug":"rollover-to-reveal-in-email","status":"publish","type":"post","link":"https:\/\/freshinbox.com\/blog\/rollover-to-reveal-in-email\/","title":{"rendered":"Rollover or Tap to Reveal Technique in Email"},"content":{"rendered":"<p>Here&#8217;s a way to implement a neat &#8220;rollover to reveal&#8221; message in email. You can send an email that has a teaser cover message that when the recipient hovers the cursor over the message it reveals a hidden surprise message. Mobile users see the message when the image is tapped.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/freshinbox.com\/blog\/wp-content\/uploads\/2015\/07\/rollover-reveal.gif\" alt=\"rollover-reveal\" width=\"406\" height=\"282\" class=\"aligncenter size-full wp-image-2069\" \/><\/p>\n<div id=\"email-me\">\n  <input type=email id=\"email-me-email\" placeholder=\"Email address\"> <input id=\"email-me-btn\" type=button value=\"See Example In Your Inbox\" style=\"-webkit-appearance: none;\">\n<\/div>\n<p>This technique is similar to the straightforward <a href=\"https:\/\/freshinbox.com\/blog\/3-steps-to-create-an-interactive-email-using-css\/\">rollover images<\/a> in email with one important difference &#8211; Instead of showing the initial image as a fallback to non-supported clients, this technique shows the revealed message.<\/p>\n<p>This way recipients using clients that don&#8217;t support the rollover technique won&#8217;t miss out on the message. They just miss out on the novelty.<\/p>\n<p><b>Users that see interactive version:<\/b><BR> iOS Mail, Android 4.x Mail, Yahoo! Mail, Outlook.com and Gmail.com (requires <a href=\"https:\/\/freshinbox.com\/blog\/interactive-emails-in-gmail-using-css-attribute-selectors\/\">attribute selector hack<\/a>).<\/p>\n<p><b>Users that see the revealed message only:<\/b><BR> Desktop Outlook, Gmail mobile apps and Gmail for business.<\/p>\n<div style=\"max-width:400px;margin:20px auto;padding:10px;border:2px solid #AC88AC;text-align:center;border-radius:3px;\">\nReady for something even more interactive?<br \/>\n<a href=\"https:\/\/freshinbox.com\/resources\/tools\/carousel\/\">Try out the Image Carousel for Email Tool<\/a>.\n<\/div>\n<p><BR><\/p>\n<h4>Difference From Regular Rollover<\/h4>\n<p>To support the reveal use-case, we will make some slight changes to the technique. Instead of placing the cover image (closed envelope) as the overlay image and the revealed image as the background image, we switch it.<\/p>\n<pre class=\"lang:default decode:true \" >&lt;table border=1 cellpadding=0 cellspacing=0 background=\"https:\/\/freshinbox.com\/examples\/rollover-reveal-simple\/images\/reveal-close-l.jpg\"&gt;\r\n&lt;tr&gt;&lt;td&gt;\r\n&lt;a class=\"reveal\" lang=\"x-reveal\" style=\"display:block;width:500px;height:400px;\" \r\n  href=\"#\"&gt;\r\n  &lt;img src=\"https:\/\/freshinbox.com\/examples\/rollover-reveal-simple\/images\/reveal-open-l.jpg\" \r\n  style=\"display:block;\" height=400 width=500 alt=\"A surprise!\" border=0&gt;\r\n&lt;\/a&gt;\r\n&lt;\/td&gt;&lt;\/tr&gt;&lt;\/table&gt;<\/pre>\n<p>The revealed image is placed as the image and the cover image is placed as the background. Then on supported clients, we initially hide the overlay image (the revealed image) showing the cover image. Then when the user hovers over the unit, the hidden overlay image containing the revealed image is shown.<\/p>\n<p>So instead of:<\/p>\n<pre class=\"lang:default decode:true \" >.rollover:hover img{\r\n    max-height: 0px;\r\n    height:0px;\r\n}<\/pre>\n<p>We reverse it and have the revealed overlay image initially hidden and then displayed when the user hovers over the area:<\/p>\n<pre class=\"lang:default decode:true \" >.reveal img{\r\n  max-height: 0px;\r\n  height:0px;\r\n}\r\n.reveal:hover img{\r\n  max-height: none;\r\n  height: auto;\r\n}  <\/pre>\n<p>This way if a client does not support interactivity, the revealed image is shown by default. This takes away the \u201csurprise\u201d or novelty, but at least the recipient will see the message.<\/p>\n<p>For regular rollovers such as a product rollover where you want to show the first image as fallback, you would continue to use the <a href=\"https:\/\/freshinbox.com\/blog\/3-steps-to-create-an-interactive-email-using-css\/\">original rollover<\/a> method. Only use this if you need to use the reveal method.<\/p>\n<p>Also you may notice that the image is wrapped with a dead link. This is needed for the hover event to fire on iOS. You could put in a real link, but then Android users who tap on the image will immediately be taken to the link.<\/p>\n<p>Alternatively you could disable interactivity on mobile and just show the revealed message using this media query:<\/p>\n<pre class=\"lang:default decode:true \" >@media screen and (max-device-width: 1024px){\r\n  .reveal img{\r\n    max-height: none !important;\r\n    height: auto !important;\r\n  }     \r\n}<\/pre>\n<p><BR><BR><\/p>\n<h4>Source Code<\/h4>\n<p data-height=\"451\" data-theme-id=\"12191\" data-slug-hash=\"RPEbmN\" data-default-tab=\"result\" data-user=\"freshinbox\" class='codepen'>See the Pen <a href='http:\/\/codepen.io\/freshinbox\/pen\/RPEbmN\/'>RPEbmN<\/a> by FreshInbox (<a href='http:\/\/codepen.io\/freshinbox'>@freshinbox<\/a>) on <a href='http:\/\/codepen.io'>CodePen<\/a>.<\/p>\n<p><script async src=\"\/\/assets.codepen.io\/assets\/embed\/ei.js\"><\/script><\/p>\n<h4>Next Step<\/h4>\n<p>I will be updating the <a href=\"https:\/\/freshinbox.com\/tools\/rollover\/\">Rollover Images for Email Tool<\/a> to support the reveal use case shortly, but if you\u2019re interested it would be a worthwhile exercise to play around!<BR><BR><\/p>\n<p><i>Note: An earlier version of this post did not include the support of mobile clients. Jaina&#8217;s comment below spurred me to make the change :)<\/i><\/p>\n<p><BR><BR><BR><br \/>\n<div style=\"padding:10px; border: 2px solid #99C731;background-color:#FFF8DC;border-radius:5px;\">\n<form action=\"https:\/\/freshinbox1.createsend.com\/t\/i\/s\/adrmi\/\" method=\"post\" id=\"subForm\">\n<span class=\"fisub_header\" style=\"font-weight:bold;\">Subscribe to the #EmailGeeks Newsletter<\/span>\n<p><input id=\"fieldEmail\" name=\"cm-adrmi-adrmi\" type=\"email\" style=\"width:90%\" required placeholder=\"Your Email Address\" \/><\/p>\n<p><button type=\"submit\">Subscribe<\/button><\/p>\n<\/form>\n<\/div> <\/p>\n<style>\n#email-me-email {\n  width:170px;\n  height:20px;\n  margin-bottom: 5px;\n  background-color: #FAFCEF;\n  font-size: 14px;\n  padding: 3px 5px;\n  display:inline-block;\n  border-radius:3px;\n  margin-left:20px;\n}\n#email-me-btn {\n  cursor: pointer;\n  font-size: 14px;\n  color: white;\n  text-decoration:none;\n  text-shadow:#555555 0 1px;\n  background-color: #7DC442;\n  padding: 5px 12px;\n  border:1px solid #559621;\n  border-radius: 5px;\n  display:inline-block;\n}\n#email-me-btn:hover {\n  background-color: #78D62C;\n}\n#email-me{\n  width: 420px;\n  padding:20px;\n  xborder:3px solid #888888;\n  xborder-radius: 5px;\n  margin:0px auto;\n}\n<\/style>\n<p><script src=\"\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/1.10.2\/jquery.min.js\"><\/script><br \/>\n<script>\n  var theEmail = null;\n  $(document).ready(function(){\n    $('#email-me-btn').click(function(){\n      theEmail = $('#email-me-email').val();\n      sendEmail(theEmail);\n    });\n    $(\"#email-me-email\").keypress(function(e) {\n      if(e.which == 13) {\n        theEmail = $('#email-me-email').val();        \n        sendEmail(theEmail);\n      }\n    });\n  });\n  var sendEmail = function(emailAddr){\n    if(!emailAddr || emailAddr.length < 12){\n      alert('Please enter an email');\n      return;\n    }\n    $('#email-me-email').val('sending...');\n    $.ajax({\n      url: \"https:\/\/freshinbox.com\/examples\/rollover-reveal-simple\/mail_example.php\",\n      data: {\n        email: emailAddr\n      },\n      success: function( data ) {\n        if(data == null || data.indexOf(\"ERROR\") != -1){\n          alert(\"There was a problem sending the email \\n\"+data);\n        }else{\n          alert(\"An email has been sent to \"+emailAddr+\"!\\n (Be sure to check the spam folder just in case)\");          \n        }\n        $('#email-me-email').val('');\n      }\n    });\n  }\n<\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s a way to implement a neat &#8220;rollover to reveal&#8221; message in email. You can send an email that has a teaser cover message that when the recipient hovers the cursor over the message it reveals a hidden surprise message&#8230;<\/p>\n","protected":false},"author":2,"featured_media":2089,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2,24,25,47],"tags":[],"_links":{"self":[{"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/posts\/1924"}],"collection":[{"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/comments?post=1924"}],"version-history":[{"count":23,"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/posts\/1924\/revisions"}],"predecessor-version":[{"id":2090,"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/posts\/1924\/revisions\/2090"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/media\/2089"}],"wp:attachment":[{"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/media?parent=1924"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/categories?post=1924"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/tags?post=1924"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}