How to use a Stylus variable in calc?
In order to use a Stylus variable inside a calc expression, one must employ the string % operator:
arrow-size = 5px
left "calc(50% - %s)" % arrow-size
How to use multiple variables Stylus in calc()?
Just wrap the values into brackets, like this:
// *.styl
$gutter = 1rem
.sizeXS-m10
width 'calc(%s / %s * %s - %s)' % (100% 12 10 $gutter)
How to calc square root in stylus
As answered there you can use the built-in math
function for this, so the custom sqrt
could look better:
sqrt(x)
return math(x, 'sqrt')
How to use a stylus variable in a selector
You have to use interpolation. In the comment Jcl has made a little mistake by not remove the quotes:
STYLUS
for $num in (1..100)
:scope[md={$num}]
width: $num + '%'
OUTPUT
:scope[md=1] {
width: 1%;
}
:scope[md=2] {
width: 2%;
}
:scope[md=3] {
width: 3%;
}
...
If you want the output with quotes you can escape like this:
:scope[md=\"{$num}\"]
Related Topics
CSS Is Not Working in My Angular Component
CSS - How to Get Rid of the Selection Rectangle After Clicking a Link
Using Nth-Child in Tables Tr Td
How to Change Extjs Grid Single Cell Background Color Depending on Value Changes
Changing Font Color of <A> Contained Within <Li>, But on Hover Over <Li>
Css: How to Set Container Size Equal to Background Image Size
Css3 Transition Only When Class Is Added, Not When Removed
CSS Media Queries to Hide and Show Page Elements
How to Stop Fouc When Using CSS Loaded by Webpack
React Native: Different Styles Applied on Orientation Change
CSS White Space at Bottom of Page Despite Having Both Min-Height and Height Tag
How to Perform Arithmetic Operations in CSS
How to Exclude a Tag from CSS Class
How to Use CSS to Vertically Center the Text in an Anchor, Within a Li
How to Set the CSS Content Property with a Google Material Icon
Angular2: How to Manually Add CSS Files by Condition to Index.Html