| Custom Form Buttons |
|
|
|
| Wednesday, 22 April 2009 08:31 | ||||||
|
You spend a lot of time and energy to make your website pages look hot only to have to ruin it with vanilla form submit buttons. No worries! LYME Team has got the answer!
First off. Make three style sheet classes, one for each state of the button. The first .button is the button in normal state. Second one .button:hover is using the built-in hover event state. Last is .button-down which is the class that represents the button when the user clicks it. Next issue is since these are graphics representing our buttons we don't want the user having to look at a "image-is-loading" box while the button picture is downloading. So we need to precache the button pictures. The button normal state should automatically be downloaded by the browser. But the other two events need the precache. There are a lot of other solutions out there. For example using Javascript to load the images. I prefer to use the CSS way, which to me is a whole lot simpler, and just make a div block that is hidden and load my images in the hidden block. The Javascript way could fail because of how each browser may handle the precaching script. Since this is a common way to precache its not likely it will fail but on any case my way seems a little easier to me. Next up is the button itself. Notice we didn't blantly overwrite the input tag. This is because that would be epic in fail. ;-) <input> can be a million different type form components and unfortunitely CSS is too stupid to know the difference. So please note... Which is why I opt to just never do it and instead link my components individually to the class. This also lets us use javascript to tweak the button. Without this we couldn't tweak the button to have normal button feel. OnMouseDown event is when the user clicks the mouse button. When they trigger that event we relink the class in javascript to button-down. When the user lets up triggering OnMouseUp or does a fly-by and triggers OnMouseOut we link the button back to the button style class. There you go. Nothing could be simpler and keep your pages right down to your HTML forms looking hot. Enjoy!
Only registered users can write comments!
Powered by !JoomlaComment 3.26
3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved." |
||||||
| Last Updated ( Wednesday, 22 April 2009 09:18 ) | ||||||


