Compass - Sprite image scaling

有些话、适合烂在心里 提交于 2019-12-10 19:46:34

问题


I'm creating a Sencha Touch web app using Compass. Had a go at inline-url but my images are huge so am looking to move them into a sprite instead (and re-use with background-size).

Currently my inline-images can be scaled because they're a single file. Sprites have positions which are generated upon creation of the sprite. When you change the sprite size using background-size you need to alter the position as well.

Is it possible to grab the index of the sprite? Then I can say that if I want it to be background-size: 50px and the index is 3 then the new background-position is 0 150px;

Can't see anything about where compass stores or gets the index of each item in the sprite. My image starts with an 'A' so is the first in the folder, is referenced first in my SCSS but it's index is 3 so I'm not sure how to work this out.


回答1:


I found this, which helped me somehow: https://gist.github.com/3410875

I'm using it in this way:

$logo-spacing: 20px;
@import "logo/*.png";
@include all-logo-sprites;

.logo-brand {
    $spriteName: brand;
    $percentage: 40;

    @include resize-sprite($logo-sprites, $spriteName, $percentage);
}

Not sure if this is answering your question though.



来源:https://stackoverflow.com/questions/12745682/compass-sprite-image-scaling

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!