How to rotate an image 180 degrees on every click with css?

Posted on 2014-08-18
Last Modified: 2014-08-18
Dear Experts,

I'm using jquery mobile to do an app, and I'm using an image to toggle the footer of my app.
The thing is that I need to animate with a rotate the image (that is a chevron arrow pointing to the top) and I want that when the user makes a tap on the image, the image will rotate 180 degrees.

My app is here: Symbiont Technologies

1. Sign In
2. Click on the blue image that has the numbers 1234.
Footerproblemscreenshots.png3. Then you click on the chevron image that is on the bottom right of the page.
That chevron image toggles the footer, but the image is static.
There's where I want to rotate that image with css on every click of the user.

Thanks in Advance.

Best Regards.
Question by:Conrado ZAVALA
    LVL 25

    Accepted Solution

    instead of hiding and showing different images, toggle a class on click.

    add a transition to #imgFooter rule:

    #imgFooter {
    height: 40px;
    width: 40px;
    position: fixed;
    bottom: 30px;
    right: 5px;
    opacity: 0.90;
    filter: alpha(opacity=90);
    z-index: 20;
    -webkit-transition: all 1s;
    -moz-transition: all 1s;
    -ms-transition: all 1s;
    transition: all 1s;

    Open in new window

    make a new class:

    -webkit-transform: rotate(180deg);
    -moz-transform: rotate(180deg);
    -ms-transform: rotate(180deg);
    transform: rotate(180deg);

    Open in new window

    toggle the arrowUp class on click.
    LVL 25

    Expert Comment

    by:Kyle Hamilton
    btw, get rid of the filter. there are no phones with old IE.

    Author Comment

    by:Conrado ZAVALA
    Hi Kyle, I've made the changes you invite me to do, but now I'm coming with this new problem.

    It is in the same URL.

    1. Sign In
    2. Click on the blue image that has the 3 little men.
    Footernewproblem.png--* You click on the chevron image and it works pretty nice, but when you go to the other page it stops making the rotate.
    3. click on the next page.
    Footernewproblem2.png--* When you click on the chevron it doesn't work.

    Do you know what's happening?

    Thank you for your help.

    Best Regards.

    Author Comment

    by:Conrado ZAVALA
    I already fix the problem Kyle. Thank you very much for your help.

    Best Regards.
    LVL 25

    Expert Comment

    by:Kyle Hamilton

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
    Read about why website design really matters in today's demanding market.
    In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
    In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…

    759 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

    10 Experts available now in Live!

    Get 1:1 Help Now