image.less 1.1 KB

123456789101112131415161718192021222324252627282930
  1. // stylelint-disable media-feature-name-no-vendor-prefix, media-feature-parentheses-space-inside, media-feature-name-no-unknown, indentation, at-rule-name-space-after
  2. // Responsive image
  3. //
  4. // Keep images from scaling beyond the width of their parents.
  5. .img-responsive(@display: block) {
  6. display: @display;
  7. max-width: 100%; // Part 1: Set a maximum relative to the parent
  8. height: auto; // Part 2: Scale the height according to the width, otherwise you get stretching
  9. }
  10. // Retina image
  11. //
  12. // Short retina mixin for setting background-image and -size. Note that the
  13. // spelling of `min--moz-device-pixel-ratio` is intentional.
  14. .img-retina(@file-1x; @file-2x; @width-1x; @height-1x) {
  15. background-image: url("@{file-1x}");
  16. @media
  17. only screen and (-webkit-min-device-pixel-ratio: 2),
  18. only screen and ( min--moz-device-pixel-ratio: 2),
  19. only screen and ( -o-min-device-pixel-ratio: 2/1),
  20. only screen and ( min-device-pixel-ratio: 2),
  21. only screen and ( min-resolution: 192dpi),
  22. only screen and ( min-resolution: 2dppx) {
  23. background-image: url("@{file-2x}");
  24. background-size: @width-1x @height-1x;
  25. }
  26. }