Text

Use jQuery to fade to a different background image on submit button hover

There’s a pretty common and nice looking that lets you fade to a different background image when you hover over a link, div, etc. For an example, see Dragon Interactive’s navigation. That method basically involves adding an empty span tag inside the link or div, and setting it to take up the full available space but be transparent. Then, on hover, you fade it into view (and you can set whatever background image you want on it so it looks nice and pretty).

However, that method doesn’t work on form submit button inputs since you can’t add HTML inside an <input> tag (since they’re self-closing). So you’re stuck trying to figure out another method. Here’s a simple one that worked for me.

Basically, instead of setting a span inside the element, you wrap the element in a div, so you’re basically doing the opposite. Then, you can set whatever background image you want on the div, and write a bit of jQuery that, on hover, fades the button to an opacity of 0.01 (so it’s transparent, showing the div’s background image instead of the button’s, but still clickable).

Here’s some code to illustrate:

The HTML for the submit button

The jQuery which wraps the submit button in a div and does the fading on hover/mouseout

The CSS to replace the button with an image (using a large negative text-indent which is just my preferred method) and to set the background image on the background div

Give me a shout if you try it out and have trouble.

Text

Clearing floats with overflow: hidden

There are a lot of methods for clearing floats. Clearfix is still popular (for some reason), and you still see a lot of <div class="clear" /> going around as well. For awhile, I used overflow: auto which worked fine except that it sometimes gave you nasty scrollbars.

Then I realized overflow: hidden does the same thing without the risk of scrollbars. Just give overflow: hidden to the container that contains the floated elements, and anything below that container will be cleared underneath it. Here’s an example:

Tags: HTML CSS
Text

Priss - a CSS print framework

You maybe have heard of Hartija or perhaps even used it at some point. I use it all the time, but noticed that maintenance on it had pretty much halted.

Therefore, like I tend to do, I forked it into Priss.

If you’re looking for a best practices print stylesheet, Priss is the way to go. Feel free to give it a whirl.

By the way, the name is a cheesy mashup of “Print” and “CSS” …please pretend it was named something cooler.

Tags: CSS Design
Text

Make link href’s visible when printing

This is one of those things that I would expect everybody to be doing by now but nobody really is.

One of the annoyances of printing is that when you print out a webpage, you can see the links but you have no idea where any of them go to. Quick fix: stick the following rules in your print stylesheet and the link’s href will be appended after it in parenthesis:

I have no idea where I first found this, so apologies to whoever first came up with it.