In most cases, I use LESS variables with predefined breakpoints for media queries, for example:
@s-max : ~"screen and (max-width: 40em)"; @m-max : ~"screen and (max-width: 50em)"; @l-max : ~"screen and (max-width: 60em)"; USAGE .some-class { color: red; @media @s-max { color: blue; } }
But sometimes I would like to be able to reference an arbitrary breakpoint in my .less stylesheet without having to set a new setpoint in my separate mixin file.
You can do it in SASS. Smeshin looks like this:
@mixin bp-min($canvas) { @media only screen and (min-width:$canvas) {@content;} } USAGE @include bp-min(750px) { //responsive styling for min-width of 750px }
In LESS, I imagine that the equivalent mixin would look something like this:
.bp-min(@min) { @media only screen and (min-width:@min)... }
The only problem is the lack of the {@content} argument in LESS, which captures the rest of the style introduced by the developer. I like SASS, but I canβt use it at work.
Does anyone know of a LESS solution to this problem?
css less media-queries
Bryce johnson
source share