Solved

Need to animate buttons on webpage

Posted on 2014-11-21
8
245 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
[X]
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
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
auto play video on web page 4 40
Need to add another Column in Powershell script output 2 33
Accordion won't close correctly 5 14
SP result not being displayed 5 44
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.
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
The goal of the tutorial is to teach the user the full work flow of how to use flash media encoder to stream onto YouTube.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

733 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