-
-
Save Sewdn/3211701 to your computer and use it in GitHub Desktop.
dynamic variables for Sass (squaring the circle :-)
This file contains hidden or 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
@mixin makecircle($height: 10px, $width: 10px) { | |
$radius: sqrt(($height * $width)/pi()); | |
@include border-radius($radius); | |
height: $radius*2; | |
width: $radius*2; | |
} | |
.myCircle { | |
@include makecircle(10px, 25px); | |
} | |
// should compile to: | |
.myCircle { | |
height:17,8412411615277px; | |
width:17,8412411615277px; | |
border-radius:8,92062058076386px; | |
// circle’s area = 250px² | |
} | |
// Okay, maybe I’m [en.wikipedia.org/wiki/Squaring_the_circle] here :-). | |
// But my real problem at hand is how to have Sass dynamically get the | |
// initial values for $height and $width, in order to have them recalculated | |
// by the mixin. Will this be possible in Sass? | |
// cfr: http://stackoverflow.com/questions/9394514/how-to-get-the-value-of-a-css-property-in-sass | |
// cfr: http://stackoverflow.com/questions/10377464/sass-get-value-of-existing-background-string-and-add-to-it |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment