_image.scss 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // Image Mixins
  2. // - Responsive image
  3. // - Retina image
  4. // Responsive image
  5. //
  6. // Keep images from scaling beyond the width of their parents.
  7. @mixin img-fluid {
  8. // Part 1: Set a maximum relative to the parent
  9. max-width: 100%;
  10. // Part 2: Override the height to auto, otherwise images will be stretched
  11. // when setting a width and height attribute on the img element.
  12. height: auto;
  13. }
  14. // Retina image
  15. //
  16. // Short retina mixin for setting background-image and -size.
  17. // stylelint-disable indentation, media-query-list-comma-newline-after
  18. @mixin img-retina($file-1x, $file-2x, $width-1x, $height-1x) {
  19. background-image: url($file-1x);
  20. // Autoprefixer takes care of adding -webkit-min-device-pixel-ratio and -o-min-device-pixel-ratio,
  21. // but doesn't convert dppx=>dpi.
  22. // There's no such thing as unprefixed min-device-pixel-ratio since it's nonstandard.
  23. // Compatibility info: https://caniuse.com/#feat=css-media-resolution
  24. @media only screen and (min-resolution: 192dpi), // IE9-11 don't support dppx
  25. only screen and (min-resolution: 2dppx) { // Standardized
  26. background-image: url($file-2x);
  27. background-size: $width-1x $height-1x;
  28. }
  29. }