Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write multiple CSS Properties on JSS-format?

I want to make some workaround for my current work that requires this to implement in order to get the right results on iOS 9.3 and its predecessors.

It requires this line of CSS to be fixed:

.wrapping-element {
  display: -webkit-box;
  display: -moz-box;
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
}

And i want to make it to JSS. My attempt is like this:

const styles = {
  root: {
    display: '-webkit-box',
    display: '-moz-box',
    display: '-ms-flexbox',
    display: '-webkit-flex',
    display: 'flex',
  }
};

But it seems not the right way to do this. Because eslint make this an error because it has multiple key. And because it's an object, only the last key:value is applied. CMIIW

like image 573
Adith Widya Pradipta Avatar asked May 07 '18 05:05

Adith Widya Pradipta


1 Answers

I was having this problem today myself, and after a bit of digging I discovered that this can be achieved using Fallbacks:

const styles = {
  root: {
    display: 'flex',
    fallbacks: [
      { display: '-webkit-box' },
      { display: '-moz-box' },
      { display: '-ms-flexbox' },
      { display: '-webkit-flex' }
    ]
  }
}

This will output:

.root {
  display: -webkit-box;
  display: -moz-box;
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
}
like image 121
James Donnelly Avatar answered Nov 08 '22 15:11

James Donnelly