Solved

Need to animate buttons on webpage

Posted on 2014-11-21
8
233 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
 

Author Closing Comment

by:canuckconsulting
ID: 40459445
Thanks Nick!

Interestingly that doesn't work for IE but looks good in Chrome.
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

912 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now