Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

70 lines (60 sloc) 1.866 kb
/*
Responsive.less
Author: Paul Mist
Twitter: @paulmist
*/
//Convert px based width to %
.width(@context:100px, @target: 100px){
@percent: (@target/@context)*100;
width: ~`@{percent} + "%"`;
}
//Convert px based padding (shorthand) to %
.padding(@context, @top: 0, @right: 0, @bottom: 0, @left: 0){
@top-percent: (@top/@context)*100;
@right-percent: (@right/@context)*100;
@bottom-percent: (@bottom/@context)*100;
@left-percent: (@left/@context)*100;
padding: ~`@{top-percent} + "% " + @{right-percent} + "% " + @{bottom-percent} + "% " + @{left-percent} + "%"`;
}
//Convert px based padding to %
.padding-top(@context, @top: 0){
@percent:(@top/@context)*100;
padding-top: ~`@{percent} + "%"`;
}
.padding-right(@context, @right: 0){
@percent:(@right/@context)*100;
padding-right: ~`@{percent} + "%"`;
}
.padding-bottom(@context, @bottom: 0){
@percent:(@bottom/@context)*100;
padding-bottom: ~`@{percent} + "%"`;
}
.padding-left(@context, @left: 0){
@percent:(@left/@context)*100;
padding-left: ~`@{percent} + "%"`;
}
//Convert px based margin (shorthand) to %
.margin(@context, @top: 0, @right: 0, @bottom: 0, @left: 0){
@top-percent: (@top/@context)*100;
@right-percent: (@right/@context)*100;
@bottom-percent: (@bottom/@context)*100;
@left-percent: (@left/@context)*100;
margin: ~`@{top-percent} + "% " + @{right-percent} + "% " + @{bottom-percent} + "% " + @{left-percent} + "%"`;
}
//Convert px based margin to %
.margin-top(@context, @top: 0){
@percent:(@top/@context)*100;
margin-top: ~`@{percent} + "%"`;
}
.margin-right(@context, @right: 0){
@percent:(@right/@context)*100;
margin-right: ~`@{percent} + "%"`;
}
.margin-bottom(@context, @bottom: 0){
@percent:(@bottom/@context)*100;
margin-bottom: ~`@{percent} + "%"`;
}
.margin-left(@context, @left: 0){
@percent:(@left/@context)*100;
margin-left: ~`@{percent} + "%"`;
}
Jump to Line
Something went wrong with that request. Please try again.