Treasureventure.ca

Arcon Picture Frames

Close Portfolio
 

Create a multi-state image mouseover using only css

I recently had a client ask me to create a mouseover menu that had 3 states. The default state would show one image set of images, then on mouseover the highlighted image would be replaced with a new image, and all the other images in the menu would fade out.

Initially I thought I was going to have to break out some jQuery to accomplish this, but after some careful research I decided to give it a try using only css3 and sprites. I was really surprised, and incredibly pleased when everything worked out better than I’d expected.

I initially created the sprite with the default state and mouseover state.

After that I began to construct the HTML and CSS needed.

</pre>
<div id="doorway"><a id="door_goldpan" href="/treasure-hunting/69-the-prospectors-challenge">Gold Panning Adventures</a>
 <a id="door_metaldetect" href="/treasure-hunting/71-metal-detecting-adventure">Detecting Earth's Treasures</a>
 <a id="door_geocache" href="/treasure-hunting/70-take-the-geocaching-challenge">The Geocaching Challenge</a>
 <a id="door_gemstone" href="/treasure-hunting/222-gemstone-mining-adventure">Gemstone Mining Adventure</a></div>
<pre>

 

#doorway:hover a {
    opacity: 0.5;
}
#door_goldpan, #door_metaldetect, #door_geocache, #door_gemstone {
    -webkit-transition: opacity .25s ease-in-out;
    -moz-transition: opacity .25s ease-in-out;
    -o-transition: opacity .25s ease-in-out;
    transition: opacity .25s ease-in-out;
    background-image: url("http://www.function505.com/wp-content/uploads/2012/03/mouseover-sprite-01.jpg");
    background-repeat: no-repeat;
    display: block;
    float: left;
    height: 226px;
    margin: 0 20px 7px 0;
    overflow: hidden;
    text-indent: 100%;
    white-space: nowrap;
    width: 330px;
}
#door_goldpan:hover, #door_goldpan:focus, #door_metaldetect:hover, #door_metaldetect:focus,
#door_geocache:hover, #door_geocache:focus, #door_gemstone:hover, #door_gemstone:focus {
    opacity: 1 !important;
}

So I combined 2 hover states to create the effect I wanted, something that all modern browsers support.

When you mouse over the parent div #doorway, all the anchor tags within are set to a 50% opacity. Mouseover the anchors themselves and their opacity is set to 100%. I added an css3 transistion on the opacity simply for esthetics.

The overflow, text-indent, and white-space properties are used to hide the anchor tag’s text in a more efficient manner, than the typical text-indent: -9999px;

Here’s an example:

Tagged , , | Leave a comment

Set adjacent css columns to the same height

This one’s been driving people nuts since we made the switch to css layouts from tables. With a little jQuery, here’s the solution I’ve used.

Just change “div” to the selector of the elements you want to equalize.

var maxHeight = 0;
$('div')
 .each(function() { maxHeight = Math.max(maxHeight, $(this).height()); })<code>
 .height(maxHeight);</code>

Once again, thanks to StackOverflow for the solution.

Tagged | Leave a comment

Help folks out when your form fails

Your form has failed, and you’ve shown your visitor an error message asking them to contact you by email. Why not take it a step further and copy the contents of the form into an email message for them?

So here’s our form submit code.

<?php
if (isset($_POST["frmSubmit"])) {
 if(!isset($_POST["name"]) || !isset($_POST["email"])) {
 header("Location: registration_sent.php?error=2");
 } else {
 $firstname = $_POST["name"];
 $email = $_POST["email"];
 $sTo = "email@example.com";
 $sSubject = "Email from example.com contact form";
 $sBody = "";
 $sBody .= "CONTACT NAME: " . $name . "\n";
 $sBody .= "EMAIL: " . $email . "\n";

 if(mail($sTo,$sSubject,$sBody,$sHeaders)){
 header("Location: contact-sent.php?error=0");
 } else {
 session_start();
 $_SESSION['message'] = $sBody;
 header("Location: contact-sent.php?error=1");
 }

}
} else { ?>
Form HTML goes here
 <?php } ?>

I’ll explain the submit code a bit. The first if statement checks if a form has been submitted. If so, the second if statement checks for the required fields, if they aren’t filled out we load our form sent page and display a missing fields error. Typically, I’d use the jQuery validation plugin nowadays, as opposed to server-side validation.

So, all our required fields are filled in, the next if statement handles submitting the form or sets up a PHP session to pass the contents of the form to the form submit page.

The form submit page handles all the “states”. Success, missing fields, or email error messages. Here’s the code that handles that.

<?php if($_GET["error"]==0) { ?>
<p>Thanks for contacting us!</p>
<?php } else if($_GET["error"]==1) {
session_start();
$email_message = preg_replace( '/\n|\r\n/', '%0D%0A', $_SESSION['message']  );
$page_message = preg_replace( '/\n|\r\n/', '<br/>', $_SESSION['message']  );
echo "<p>We're sorry, but we couldn't send your message. We've copied your message and you can send it by email to <a href='mailto:email@example.com?Subject=Email from example.com contact form&body=" . $email_message ."'>email@example.com</a>.</p><p>Here's a copy of what you're sending:</p><p>" . $page_message . "</p>";
} else if($_GET["error"]==2) {
echo "<p>Some fields were missing. Please press the \"Back\" button on your browser and fill in all fields marked with *</p>";
}
?>

We’re interested in error == 1.

I created 2 variables containing the content from the form, using preg_replace to prepare one formatted for email, the other as html. Then the little used &body= attribute gets the email message. I display what they’ve submitted as another fallback in case there is a formatting issue with the email link, it allows visitors to copy the content into an email message.

Credit where credit is due, the following links helped me with this:
http://stackoverflow.com/questions/1517102/replace-newlines-with-br-tags-but-only-inside-pre-tags
http://stackoverflow.com/questions/703601/posting-variables-in-php

Tagged , | Leave a comment

Guidelines for HTML email’s

This was provided to me by an agency that I was doing some work for, so I take no credit for it. It’s ridiculously thorough and I find myself referring back to it each time I build an email campaign for a client.

General Guidelines

  • Use tables for layout
  • Do not use rowspan in tables (see example below).
  • Do not use background images if your design is depends on the image (Note: Outlook 2007/2010 does not support background images)
  • Use absolute urls for links
  • Use target=”_blank” for all links
  • Use empty columns/rows for padding when possible; padding-top in a <TD> will affect the adjacent <TD>; sometimes padding-right will push out the design to the right
  • Use simple inline styles; styles in the head of a document will be removed by most webmail clients. Do not use external style sheets.
  • Do not define attributes in the body tag such as any margin or color settings. <BODY> is often stripped out by web mail clients.
  • Use inline styles to define text formatting (<td style=”font-family:arial…;font-size:12px;color:#000000;”>)
  • Links may be styled but may not render properly; use style=”text-decoration:underline” to ensure that links will be underlined
  • Use alt attribute for images
  • Use <BR> instead of <P>; <P> tags will render incorrectly in webmail clients as they are generally defined by the webmail’s style sheet.
  • Avoid using image maps
  • Do not use forms
  • Do not use JavaScript
  • Do not use DHTML
  • Do not use Flash
  • Do not use Streaming Video

Test your design in multiple email and webmail clients (Outlook 2007 and Hotmail and Gmail using IE7, Firefox, etc). Try to test using a deployment tool such as MailChimp
As mentioned above, rowspan in TD tags is not supported in all email clients. To get around this you must use nested tables. For example the table below would be rendered as follows:

Cell 1
Cell #2 Row 1
Cell #2 Row 2
<table>
<tr>
<td> Cell #1</td>
<td>
<table>
<tr><td> Cell #2 – Row #1</td></tr>
<tr><td> Cell #2 – Row #2</td></tr>
</table>
</td>
</tr>
</table>

The following HTML tags should not be used in your HTML email, because several webmail applications and email clients are removing or ignoring these tags.

  • DOCTYPE
  • Base tag <BASE>
  • Link tag <LINK>
  • Script tag <SCRIPT></SCRIPT>
  • Applet tag <APPLET></APPLET>
  • Frameset tag <FRAMESET></FRAMESET>
  • Frame tag <FRAME>
  • IFrame tag <IFRAME></IFRAME>
  • Div tag <div></div>
  • Span tag <span></span>

Considerations for images

Some webmail clients will add a transparent border to all images. This results in gaps showing between any adjacent images. To fix this, use style=”display:block;” for all images that are in separate table cells. If the image is positioned beside any other element and they are not in separate table cells, such as another image or text, then use style=”display:inline;” to avoid the images wrapping to the next line.

Outlook 2007 HTML Rendering Issues

Microsoft Office Outlook 2007 uses the HTML parsing and rendering engine from Microsoft Office Word 2007 to display HTML message bodies.

Yes, you read that correctly. Word is used to render HTML emails in Outlook 2007.

Here are a few highlights of the limitations:

  • no support for background images (HTML or CSS)
  • no support for forms
  • no support for Flash, or other plugins
  • no support for CSS floats
  • no support for replacing bullets with images in unordered lists
  • no support for CSS positioning

Plain-Text Email Design Checklist

  • Use a simple plain-text program. Microsoft Word will NOT work.
  • Restrict each line to 65 characters offers the greatest protection from jagged formatting problems
  • Bullet points are key. Plain-text emails are harder to read, so break it into chunks that are easier to skim and scan. Use little characters like (*) to make bullet points, and use ====== as line separators.
  • In plain-text emails, you can’t code hyperlinks like “Click here to hyperlink” You just enter a URL like: http://www.hyperlink.com/tryit.phtml and the user will see it.
  • The following characters are absolutely safe to use in your plain-text emails:
  • a b c d e f g h i j k l m n o p q r s t u v w x y z
  • A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
  • 0 1 2 3 4 5 6 7 8 9
  • ” % & ‘ ( ) * + , – . / : ; < = > ? _
  • The solution is to justify your text so that it still looks passable in other fonts. Be particularly careful when centering or right-justifying text using the space bar.
Tagged | Leave a comment

Iteration

Broken layoutYou can see that the site’s layout is somewhat broken at this point. Usually this is something that gets caught prior to a site going live, but I’m also using this site as an experiment in exposing the process of design. Underestimating the necessary heights of backgrounds is something that comes up often enough. In my case, I’d like to try and find a solution that doesn’t require an even larger background image.

Edit: Got it! A little futzing with the css and everything came out as I wanted it to.

Tagged | Leave a comment

The Process

I find looking at really amazing work really frustrating at times. Looking at the final site, brochure, whatever, never gives you a sense of the process the designer used to complete the project.

It always appears as if these amazing ideas always spring forth from the minds of designers fully formed and realized. Rarely can you see the half dozen false starts, the wholesale throwing out of ideas, or the compromises that had to be incorporated to satisfy everyone involved in the process. Jaco Joubert at Guestlist was kind enough to put together a great video of the entire process of redesigning their homepage.

To me, these inside looks inside the process are much more instructive than the final pieces themselves. You can see what ideas carry through, what works, what doesn’t, and how the whole thing comes together. As time consuming as this can be, I wish more designers would share this part of their jobs. I think we’d all be better off for it.

Tagged | Leave a comment

Just a little more…

Well, as you can see I’m still moving forward. With the use of jQuery I’ve now got a fancy slider that will remember it’s state! The coverflow style scroller was part of my original comp, but I’m not sure if I like it in practice. Now that I’m playing with it, it feels a bit overdone.

Next I plan on fleshing out the samples of work, cleaning up the tagging interface on the right there, and probably finding a new image scroller.

Tagged | Leave a comment

Wow! Soft Launch!

Well here we go. The template is completed, so I’d call this an Alpha release.

No content, pretty minimal functionality, but the template is built, and that’s been the hard part up to this point.

Tagged | Leave a comment

Talk about small steps

Just uploaded the new favicon! In actuality a lot of work has been going on behind the scenes. The new layout is complete, and we’re moving onto markup.

Tagged | Leave a comment

How to build a portfolio in many small steps

Wow, the default template for Joomla. Not ugly, but not what I’m looking for.

Over the next undetermined amount of time, this will become my portfolio. Thanks to an offer of free hosting things have gotten a bit of a kick start. The next step is to delete all the sample content and menus that are installed by default.

My goal is to show the process in building this site and share what I learn, both as a reference for myself and others. With a bit of luck things will move forward at something greater than a glacial pace.

Tagged | Leave a comment