Created
October 30, 2014 08:27
-
-
Save dtbaker/abfe70034aa9f4e993a6 to your computer and use it in GitHub Desktop.
simple less mixin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @highdpi: ~"((-webkit-min-device-pixel-ratio: 1.5), (min--moz-device-pixel-ratio: 1.5), (-o-min-device-pixel-ratio: 3/2), (min-resolution: 1.5dppx))"; | |
| .double_background(@url){ | |
| background: ~"@{url}"; | |
| @media @highdpi { | |
| background: ~`@{url}.replace(/images\//g, 'images/2x/')`; | |
| } | |
| } | |
| #your_element{ | |
| .double_background('#f3dbab url(images/icon-cart.png)'); | |
| background-repeat: no-repeat; | |
| background-size: 12px 10px; | |
| background-position: right; | |
| background-origin: padding-box; | |
| } | |
| /*** it outputs the below CSS: ***/ | |
| #your_element { | |
| background: #f3dbab url(images/icon-cart.png); | |
| background-repeat: no-repeat; | |
| background-size: 12px 10px; | |
| background-position: right; | |
| background-origin: padding-box; | |
| } | |
| @media ((-webkit-min-device-pixel-ratio: 1.5), (min--moz-device-pixel-ratio: 1.5), (-o-min-device-pixel-ratio: 3/2), (min-resolution: 1.5dppx)) { | |
| #your_element { | |
| background: #f3dbab url(images/2x/icon-cart.png); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment