question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is it possible to use the negative value of a variable?

See original GitHub issue

So if I have:

@value button-size: 55px;

Can I do something like:

position: absolute;
left: -button-size;

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:20
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

236reactions
joshwnjcommented, Aug 26, 2016

I haven’t tried this, but you might be able to use postcss-calc and do:

left: calc(button-size * -1);
123reactions
apacsacommented, Apr 10, 2017

You can achieve that with CSS variables:

:root {
  --button-size: 55px;
}

.someclass {
  position: absolute;
  left: calc(-1 * var(--button-size));
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Can you have a negative variable in algebra (not to ... - Quora
No you cannot because the negative sign in front of any variable is the coefficient of the variable which is (-1). For example:...
Read more >
How to Multiply a Negative Variable With a Positive Variable
Add a negative sign to the answer. A negative variable times a positive variable will produce a negative product. For example, -x *...
Read more >
Using negative CSS Custom Properties - Stack Overflow
As of this posting, March 2018, the only way to use negative custom properties is by multiplying it by -1 with the calc...
Read more >
Getting Rid of Negative Variables (Simplifying Math) - YouTube
Solving equations with negative variables made easy with this quick tutorial.
Read more >
Negative numbers, variables, number line - Khan Academy
Normally, to the left of the zero are negative numbers and to the right of the zero are positive numbers in number line,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found