Screen Agent

Arguments

NameTypeDescription
$resolutionstring,
number (with unit)

Accepts only one argument and three different values which targets the screen resolution: 1x, 2x and 3x. Or you can pass a custom numeric value with dpi and dpcm units.

* The string values must be wrapped with the quotation signs.

Examples

Based on the assumption above, we can give the following example.

.element{
  background-image: url(https://sample-site.com/images/sample-image-1920x1080.jpg);
  @include screen-agent("2x"){
    background-image: url(https://sample-site.com/images/sample-image-3840x2160.jpg);
  }
}
//CSS Output
.element {
  background-image: url(https://sample-site.com/images/sample-image-1920x1080.jpg);
}
@media (min-resolution: 192dpi) {
  .element {
    background-image: url(https://sample-site.com/images/sample-image-3840x2160.jpg);
  }
}

Now, let’s try it with a custom value.

.element{
  background-color: green;
  @include screen-agent(192dpi){
    background-color: teal;
  }
}
//CSS Output
.element {
  background-color: green;
}
@media (min-resolution: 192dpi) {
  .element {
    background-color: teal;
  }
}