Home  >  Q&A  >  body text

javascript - How to switch the sprite image and font color by clicking on the navigation?

As shown in the picture, but there are four pages in the picture. What I want to do now is click on the icon and change the font color on a page.

Then the icon is made of sprite

The following is a screenshot of the code, mainly for the Sprite image

曾经蜡笔没有小新曾经蜡笔没有小新2710 days ago1618

reply all(2)I'll reply

  • 世界只因有你

    世界只因有你2017-05-19 10:45:10

    background-position Change the background position and make two sets, one is gray and the other is colored

    Just use color to make the font

    In addition, if you don’t want to use two sets of pictures, you can use css mask, but the compatibility is not very good

    Now that you have written a set of background-position classes, just switch the classes

    reply
    0
  • 漂亮男人

    漂亮男人2017-05-19 10:45:10

    $(".sctop li").click(function(){
            $(this).addClass("hover").siblings().removeClass("hover")
            var index = $(this).index();
            $(".spp .sp1:eq("+ index +")").css("height","auto").siblings().css("height","0px");
    })
    

    Please refer to this

    reply
    0
  • Cancelreply