Avatar of canuckconsulting
canuckconsultingFlag for United Kingdom of Great Britain and Northern Ireland

asked on 

Need to animate buttons on webpage

I have a web page with buttons as shown here:
User generated image
They work fine but there is no visual indication when the get clicked.  What is the best and quickest way for me to visually respond to a click?  Here is one of the buttons files as an example:

User generated image
For image tools I have Gimp though I am a novice with it.  I also have the Jquery and jqueryUI libraries working on this page if that's of any use.
Web DevelopmentHTMLImages and Photos

Avatar of undefined
Last Comment
Elxn
Avatar of Elxn
Elxn
Flag of United States of America image

You can use jquery to do something like this easily.

Just give your images a class and a tabindex:
<img class="photo" tabindex="0" src="pic.jpg" />

Open in new window


Then use css to define a new image for your image when it has the focus (i.e. is clicked on).
.photo:focus{
   background:url(click-pic.jpg);
}

Open in new window


Then use jquery to remove the focus after a short period of time:
$( ".photo" ).click(function() {
    $(this).blur().delay(500);
});

Open in new window


That should probably be a really easy way to do this.
Avatar of Elxn
Elxn
Flag of United States of America image

you'll probably want to use a unique ID instead of a class as you'll need various css for the different pictures.  Forgot to do that.  Just define css for each unique ID and you can change the code accordingly.

Or to make your life easier you can change the color of the class's css and just modify the way the image looks when they click on it.  Like so:

.photo:focus{
	filter: saturate(500%);
	-webkit-filter: saturate(500%);
	-moz-filter: saturate(500%);
	-o-filter: saturate(500%);
	-ms-filter: saturate(500%);
}

Open in new window


You won't have to mess around with all those ID's in your CSS if you do it this way...
ASKER CERTIFIED SOLUTION
Avatar of Elxn
Elxn
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of canuckconsulting

ASKER

Thanks Nick!

Interestingly that doesn't work for IE but looks good in Chrome.
Avatar of Elxn
Elxn
Flag of United States of America image

Hmm.  I'm pretty new to jQuery, but I am pretty sure jQuery works very hard to be cross-browser compatible so the problem is probably elsewhere.  My guess is that IE doesn't allow you to set a tab index for elements like a img tag.
Avatar of Elxn
Elxn
Flag of United States of America image

Solution, just fake IE out by using links...  Check out the solution for IE here
Avatar of Elxn
Elxn
Flag of United States of America image

and remember you should be able modify the saturation (or other aspects) with the CSS i already gave you in an earlier comment so you don't have to specify unique images for each button and button focus.
Avatar of Elxn
Elxn
Flag of United States of America image

Oh just found out CSS filter support is not in IE... So forget that idea...
Web Development
Web Development

Web development includes all aspects of presenting content on intranets and the Internet, including delivery development, protocols, languages and standards, server software, browser clients, databases and multimedia generation.

77K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo