Questions tagged [css-variables]

Custom properties (or CSS variables) allow to define stylesheet-wide values identified by a token and usable in all CSS declarations.

Custom properties (sometimes referred to as CSS variables or cascading variables) are entities defined by CSS authors that contain specific values to be reused throughout a document.

developer.mozilla

They are set using custom property notation (e.g., --main-color: black;) and are accessed using the var() function (e.g., color: var(--main-color);).

Example

/* Declaring a variable */
:root {
  --main-bg-color: brown;
}

/* Using the variable */
element {
  background-color: var(--main-bg-color);
}
625 questions
0
votes
1 answer

IE fallback of css variables without ActiveX warning

I am trying to do a graceful fallback for IE with CSS variables. So I did this: body { background: brown; background: var(--main-bg-color); } This works, however IE warns of ActiveX component and makes me allow it. I attached a screenshot…
Noitidart
  • 35,443
  • 37
  • 154
  • 323
0
votes
0 answers

Dynamically Scaling Style Sheets Via Passing Javascript Variables -> CSS

How exactly would I pass a javascript variable to a css file in such as that, the css file can use that variable to scale the page dynamically. I have already figured out a hack to do it with a single javascript variable using the REM unit. var…
user7892745
0
votes
1 answer

Bash script for producing Google Font css PostCSS artifacts?

I'm looking for a few sed expressions that I can use to produce some postcss artifacts. It's possible that I should break this up into 2 questions. Just let me know. I'm creating this superfly-css-utility-fonts module. It's going to have font…
Ole
  • 41,793
  • 59
  • 191
  • 359
0
votes
1 answer

How to import variables from typescript to sass? (Angular2 application)

I am writing application (Angular2 framework). And now I want to make different variables in sass files at development and production. For example I want to use this solution: @if $prod == true { $background-color: #fff; } @else { …
John Doe
  • 3,794
  • 9
  • 40
  • 72
0
votes
1 answer

Ways to define CSS variables from JSON file or from typescript files?

I want to define CSS variables like in Sass. Something like: .someClass { background-image: $imageLink; color: $someColor; } And i Want to define $imageLink and $someColor in my class or in json file. Can i do this without Sass or Less? (Or…
John Doe
  • 3,794
  • 9
  • 40
  • 72
0
votes
1 answer

css: transform + 2 css variables

I have the following css on a series of elements. #foo-parent { --rotation: 45deg; } @media (max-width: 1680px) { .foo { --multiplier: 8.33; } } /* a number of other nearly identical media queries defining different values for…
BrianFreud
  • 7,094
  • 6
  • 33
  • 50
0
votes
1 answer

Chrome and Firefox giving different results on JavaScript file import of CSS variable

Chrome 51 results Firefox results test.js (function(){ let template = `