_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. @mixin img-retina($file-1x, $file-2x, $width-1x, $height-1x) {
  18. background-image: url($file-1x);
  19. // Autoprefixer takes care of adding -webkit-min-device-pixel-ratio and -o-min-device-pixel-ratio,
  20. // but doesn't convert dppx=>dpi.
  21. // There's no such thing as unprefixed min-device-pixel-ratio since it's nonstandard.
  22. // Compatibility info: https://caniuse.com/#feat=css-media-resolution
  23. @media only screen and (min-resolution: 192dpi), // IE9-11 don't support dppx
  24. only screen and (min-resolution: 2dppx) { // Standardized
  25. background-image: url($file-2x);
  26. background-size: $width-1x $height-1x;
  27. }
  28. @include deprecate("`img-retina()`", "v4.3.0", "v5");
  29. }