Last active
August 29, 2015 14:04
-
-
Save daleyjem/024052770bdf04894792 to your computer and use it in GitHub Desktop.
Extends Bootstap: Makes any object adjust width/height to an aspect ratio
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
@screen-xs: 640px !default; | |
@screen-sm: 768px !default; | |
@screen-md: 1024px !default; | |
@screen-lg: 1280px !default; | |
.ratio { | |
position: relative; | |
&:before { | |
content: ''; | |
display: block; | |
} | |
} | |
.ratio-content { | |
position: absolute; | |
left: 0; | |
top: 0; | |
right: 0; | |
bottom: 0; | |
} | |
.make-ratio(@w, @h) { | |
@perc: ((@h/@w)*100)%; | |
.ratio-xs-@w-@h { | |
@media screen and (min-width: @screen-xs) { | |
padding-top: @perc; | |
} | |
} | |
.ratio-sm-@w-@h { | |
@media screen and (min-width: @screen-sm) { | |
padding-top: @perc; | |
} | |
} | |
.ratio-md-@w-@h { | |
@media screen and (min-width: @screen-md) { | |
padding-top: @perc; | |
} | |
} | |
.ratio-lg-@w-@h { | |
@media screen and (min-width: @screen-lg) { | |
padding-top: @perc; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment