Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to supported retina @2x, @3x #86

Closed
yutucc opened this issue Mar 2, 2017 · 5 comments
Closed

How to supported retina @2x, @3x #86

yutucc opened this issue Mar 2, 2017 · 5 comments

Comments

@yutucc
Copy link

yutucc commented Mar 2, 2017

Hello, I want to realize function, like this:

In /src/images/slice/ have two pic: test.png and test@2x.png

Css In

.icon-test {
    width: 32px;
    height: 32px;
    background-image: url(../slice/test.png);
}

Css Out

.icon-test {
    background-image: url(../sprite/style-index.png);
}

// Retina 2x supported
@media only screen and (-webkit-min-device-pixel-ratio: 2),
only screen and (min--moz-device-pixel-ratio: 2),
only screen and (-webkit-min-device-pixel-ratio: 2.5),
only screen and (min-resolution: 240dpi) {
.icon-test { 
    background-image:url("../sprite/style-index@2x.png");
    background-position: -36px -66px;
    background-size: 32px;
}
}

reference: gulp-tmtsprite

@vvasilev-
Copy link
Member

Hey @Nicholasnc,

Sorry for the late response. Please set retina option to true and the plugin will start to generate the necessary CSS rules. 😄

@yangbin1994
Copy link

just set retina

@vvasilev-
Copy link
Member

@yangbin1994 Yes, just set the retina option.

@Lkroner
Copy link

Lkroner commented Mar 17, 2018

Will this retina functionality support 3x images as well? Something like this. I don't see anything in your documentation about it.

@vvasilev-
Copy link
Member

@Lkroner The retina option supports 3x images because of these lines. If something doesn't work as you expected, you can use onUpdateRule hook to implement the desired behavior. Here is an example - https://github.com/2createStudio/postcss-sprites/blob/master/examples/output-dimensions.md.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants