Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSS

How to do addition or subtraction on CSS Variables?

:root {
  --margin: 50px;
  --margin--: calc(var(--margin) * -1));
 /* 
 while you may simply write like below
 but I love to use as above 
 coz, we'll only need to change value 
 in one place if needed
 */
 /* --margin--: -50px; */
}

.positive-margin {
  margin: var(--margin);
}
.negative-margin {
  margin-left: var(--margin--);
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #How #addition #subtraction #CSS
ADD COMMENT
Topic
Name
2+9 =