how can i use max()/min() as css-math-functions instead of stylus-bulidin-functions
Asked Answered
M

2

7

such as

.some-class
  position absolute
  left max(0px, 20vh - 100px)

my intention was calling https://developer.mozilla.org/en-US/docs/Web/CSS/max

but due to http://stylus-lang.com/docs/bifs.html#mina-b, in this case, the 'left' will always be '0px'

how can i solve it?

Matti answered 26/12, 2019 at 9:15 Comment(2)
CSS Literal, maybe?Aksel
@ÁlvaroGonzález you are right, helpful!Matti
G
5

I found this slightly hacky solution that seems to work:

max-width: "min(60vh, 580px)" % null;

Basically you're using this syntax that normally is used to apply a variable to a string, but you're replacing nothing with nothing, so it resolves to the actual rule you want.

Gudren answered 12/8, 2020 at 16:19 Comment(1)
max-width: "min(%s)" % (60vh, 580px)Discomfortable
F
5

As discussed here, the current best workaround is @css{}:

left @css{max(0px, 20vh - 100px)}
Fiertz answered 16/2, 2022 at 22:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.