background-size with background-position doesn't scale the position?

前端 未结 6 1664
轮回少年
轮回少年 2021-02-05 13:16

I\'ve a sprite of 62 images of 91 * 91px, which makes the whole thing 91 * 5642 px. They\'re displayed in sort of a dynamic grid that grows and shrinks depending on user/pointer

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-05 14:14

    I think the answer should be simple,

    I have updated the fiddle,

    Please check it,

    If you specify style like this, it should solve the problem easily...

    a {
     display: block; /* always: */
     width: 91px;
     height: 91px;
     background: black url(//hotblocks.nl/tests/gamessprite.gif) no-repeat 0 0;
     background-size: 100% auto;
     /* inline: */
     background-position: 0% 3.30%; /* this will do the trick */ 
    }
    a:hover {
     width: 150px;
     height: 150px;
    }
    

    Please reply if any concern...

提交回复
热议问题