Skip to content

Instantly share code, notes, and snippets.

@pjc0247
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pjc0247/7fd55b2a0dd80753db83 to your computer and use it in GitHub Desktop.
Save pjc0247/7fd55b2a0dd80753db83 to your computer and use it in GitHub Desktop.
selector {
.size(30px, 40px); /* set default */
.size('tablet', 25px, 35px);
.size('mobile', 20px, 30px);
.position(100px, 40px);
.position('tablet', 120px, 50px);
.position('mobile', 130px, 60px);
}
.position(@x: ~'', @y: ~'') {
left : @x;
top : @y;
}
.position(@mode, @x, @y){
@media screen and (max-width: @@mode){
left : @x;
left : @y;
}
}
.size(@w: ~'', @h: ~'') {
width : @w;
height : @h;
}
.size(@mode, @w, @h){
@media screen and (max-width: @@mode){
width : @w;
height : @h;
}
}
var configs = {
presets : {
mobile : 640,
tablet : 1024
}
};
var current_mode = '';
var setup = function(){
less.modifyVars(config.presets);
}();
$(window).resize(function(){
var w = $(window).width();
current_mode = 'default';
for(i=0;i<config.presets.length;i++){
var preset = config.presets[i];
if(w < preset.max_width)
current_mode = preset.name;
}
less.modifyVars({
'@mode' : current_mode
});
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment