question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to supported retina @2x, @3x

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
vvasilev-commented, Mar 17, 2018

@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.

0reactions
Lkronercommented, 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Retina Web Graphics Explained: 1x versus 2x (Low‑Res ...
Therefore it's best to create both 1x and 2x for desktops. Should You Make 3x Graphics? There are even higher resolution 3x displays,...
Read more >
Optimizing Images for Retina Displays | SLEEPLESS MEDIA
How To Code 2x Graphics. The width should be set to half the width of the image file. For example, if the image...
Read more >
How to cap image fidelity to 2x and save 45% image weight ...
So the first thing we started doing was to provide both a standard image and an image optimized for Retina displays, using the...
Read more >
Retina image support (@1x @2x @3x) - Drupal Answers
Configure three normal image styles that produce the desired resolutions for each of the 1x, 2x, and 3x pixel densities.
Read more >
A guide for creating a better retina web - Ivo Mynttinen
I recommend using the same file name for both, but adding “@2x” at the end for the retina assets (known from iOS development)....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found