image.less 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  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. .img-responsive(@display: block) {
  8. display: @display;
  9. width: 100% \9; // Force IE10 and below to size SVG images correctly
  10. max-width: 100%; // Part 1: Set a maximum relative to the parent
  11. height: auto; // Part 2: Scale the height according to the width, otherwise you get stretching
  12. }
  13. // Retina image
  14. //
  15. // Short retina mixin for setting background-image and -size. Note that the
  16. // spelling of `min--moz-device-pixel-ratio` is intentional.
  17. .img-retina(@file-1x; @file-2x; @width-1x; @height-1x) {
  18. background-image: url("@{file-1x}");
  19. @media
  20. only screen and (-webkit-min-device-pixel-ratio: 2),
  21. only screen and ( min--moz-device-pixel-ratio: 2),
  22. only screen and ( -o-min-device-pixel-ratio: 2/1),
  23. only screen and ( min-device-pixel-ratio: 2),
  24. only screen and ( min-resolution: 192dpi),
  25. only screen and ( min-resolution: 2dppx) {
  26. background-image: url("@{file-2x}");
  27. background-size: @width-1x @height-1x;
  28. }
  29. }