Created
August 31, 2015 10:06
-
-
Save Razenbull/217fa13815eab97507cd to your computer and use it in GitHub Desktop.
helper mixin to display responsive images
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// helper mixin to display retina images | |
// | |
// @param {List *required} nth($display, 1) - display | |
// @param {List *optional} nth($display, 2) - width | |
// | |
// image-1x is display and hide on high resolution screens | |
// image-2x is hide and display on high resolution screens | |
// | |
// @use @include image-retina(inline, 60px); | |
@mixin image-retina($display...) { | |
> .image-1x { | |
display: nth($display, 1); | |
@include hdpi(2) { | |
display: none; | |
} | |
} | |
> .image-2x { | |
display: none; | |
@include hdpi(2) { | |
display: nth($display, 1); | |
} | |
} | |
@if length($display) > 1 { | |
> .image-1x, | |
> .image-2x { | |
width: nth($display, 2); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<a class="retina" href="#"> | |
<img class="image-1x" alt="youtic" src="/images/logoyoutic.png"> | |
<img class="image-2x" alt="youtic" src="/images/[email protected]"> | |
</a> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment