Workaround for CSS variables in IE?

后端 未结 10 1767
Happy的楠姐
Happy的楠姐 2020-12-13 17:02

I\'m currently developing a web application in Outsystems in which I have the need to customize the CSS, in which I\'m using variables. I need to guarantee the app works cro

10条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-13 17:50

    Another way to do it is declaring colors in a JS file (in my case I'm using react) and then just use the variable you defined in the JS file.

    For example:

    • in globals.js
    export const COLORS = {
      yellow: '#F4B400',
      yellowLight: '#F4C849',
      purple: '#7237CC',
      purple1: '#A374EB',
    }
    
    • in your file
    import { COLORS } from 'globals'
    

    and then just use COLORS.yellow, COLORS.purple, etc.

提交回复
热议问题