Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 2 of 2
  1. #1
    Junior Member
    Join Date
    Oct 2014
    Posts
    1
    Member #
    40508

    CSS Sprite --active button not working

    Hi

    I have created three button images that have been placed into one file, which I'm using for a CSS Sprite.

    Here is my HTML:

    <li><a href="myths.html" id="myths"><img src="images/myths.jpg" alt="logo" width="113" height="43" /></a></li>

    On the MAIN page I have two buttons setup that are HOME and MYTHS.


    Here is my CSS:

    #myths {
    background: url(../images/sprite_2.png) no-repeat;
    width: 115px;
    height:43px;
    display: block;
    text-indent: -9999px;
    }

    #myths:hover
    { background-position: 0 -80px;
    }

    #myths:active {
    background-position: 0 -30px;
    }


    When I place the cursor over the MYTHS button I achieve the hover effect, yet when I click on the MYTHS button to go to the Myth page, the MYTHS button is not active, indicating that this the selected page you are on.

    Any timely suggestions to resolve this situation would be greatly appreciated.


    sahstr

  2.  

  3. #2
    Senior Member sasha_bolcina's Avatar
    Join Date
    Sep 2014
    Location
    Serbia
    Posts
    274
    Member #
    40099
    Liked
    47 times
    The problem was explained once here... However

    :active is working only if you stay on that page. It indicates last clicked item (can be whatever, not only link). If page is reloaded, there is no information of last clicked item anymore.

    Solution is to make a class for active button. Something like:

    Code:
      a.active {
        background-position: 0 -30px;
      }
    And add the class to link of active page

    Code:
    <li><a href="myths.html" id="myths" class="active"><img src="images/myths.jpg" alt="logo" width="113" height="43" /></a></li>


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 06:45 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com