Created
March 18, 2015 13:41
-
-
Save mattmckenny/6f3701852be4ff737944 to your computer and use it in GitHub Desktop.
Bootstrap/Less mixin to add responsive media query within original selector's declaration
This file contains 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
// | |
// Load core variables | |
// -------------------------------------------------- | |
@import "variables.less"; | |
.breakpoint(@class, @rules) when (@class = xs) { | |
@media (min-width: @screen-xs-min) and (max-width: @screen-xs-max) {@rules();} | |
} | |
.breakpoint(@class, @rules) when (@class = sm) { | |
@media (min-width: @screen-sm-min) and (max-width: @screen-sm-max) {@rules();} | |
} | |
.breakpoint(@class, @rules) when (@class = md) { | |
@media (min-width: @screen-md-min) and (max-width: @screen-md-max) {@rules();} | |
} | |
.breakpoint(@class, @rules) when (@class = lg) { | |
@media (min-width: @screen-lg-min) {@rules();} | |
} | |
// Example Usage | |
.my-class { | |
height: 150px; | |
.breakpoint( md, { | |
height: 125px; | |
}); | |
.breakpoint( sm, { | |
height: 100px; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment