Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Need to animate buttons on webpage

Posted on 2014-11-21
8
243 Views
Last Modified: 2014-11-22
I have a web page with buttons as shown here:
All the Buttons
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:

Back Button
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.
0
Comment
Question by:canuckconsulting
  • 7
8 Comments
 
LVL 2

Expert Comment

by:Elxn
ID: 40458138
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.
0
 
LVL 2

Expert Comment

by:Elxn
ID: 40458147
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...
0
 
LVL 2

Accepted Solution

by:
Elxn earned 500 total points
ID: 40458198
Oh I should also say I made a mistake in my first comment.  The CSS needs to be changed.

Change your focus css to:
.photo:focus{
   content:url("click-pic.jpg");
}

Open in new window


setting the background image was a mistake.. Sorry!

Here is a working example: example
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

Author Closing Comment

by:canuckconsulting
ID: 40459445
Thanks Nick!

Interestingly that doesn't work for IE but looks good in Chrome.
0
 
LVL 2

Expert Comment

by:Elxn
ID: 40460139
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.
0
 
LVL 2

Expert Comment

by:Elxn
ID: 40460148
Solution, just fake IE out by using links...  Check out the solution for IE here
0
 
LVL 2

Expert Comment

by:Elxn
ID: 40460150
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.
0
 
LVL 2

Expert Comment

by:Elxn
ID: 40460158
Oh just found out CSS filter support is not in IE... So forget that idea...
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The goal of the tutorial is to teach the user how to make his/her own presets while editing so it is easier to edit there photos. Create a preset you like and copy that setting then save it in to your presets folder.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question