Skip to content

Instantly share code, notes, and snippets.

@dflynn15
Last active August 29, 2015 14:00
Show Gist options
  • Save dflynn15/a4d13309f424e35a997f to your computer and use it in GitHub Desktop.
Save dflynn15/a4d13309f424e35a997f to your computer and use it in GitHub Desktop.
Conditional Media Query Mixin for LESS.
/*
* This is a LESS port of Sparkbox's module-based media queries mixin in SASS
* https://github.com/sparkbox/SB-Media
*
* Example use: http://codepen.io/dflynn15/pen/AHadk
* body{
* background-color:red;
*
* .sb-media(40em ,{
* background-color: blue;
* });
* }
*/
@no-mq-support: 'false';
@no-mq-threshold: 60em;
.sb-media(@query, @rules) when (@no-mq-support = 'false'){
@media all and (min-width: @query) { @rules(); }
}
.sb-media(@query, @rules) when (@no-mq-support = 'true') and (@query < @no-mq-threshold){
@rules();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment