_image.scss 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  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),
  24. // IE9-11 don't support dppx only screen and (min-resolution: 2dppx) {
  25. // Standardized
  26. background-image: url($file-2x);
  27. background-size: $width-1x $height-1x;
  28. }
  29. @include deprecate('`img-retina()`', 'v4.3.0', 'v5');
  30. }