According to https://facebook.github.io/react/tips/inline-styles.html
CSS styles need to be passes as an object to the component. However, if you are trying to use transform styles you will get an error.
According to https://facebook.github.io/react/tips/inline-styles.html
CSS styles need to be passes as an object to the component. However, if you are trying to use transform styles you will get an error.
Translate also wasn't working for me. I fixed it by adding 'px' behind the var.
ES6 code:
render() {
const x = 100;
const y = 100;
const styles = {
transform: `translate(${x}px, ${y}px)`
};
return (
<div style={styles}></div>
);
}
This can be done using string template literals ` as your value for the transform key:
const styles = {
logo: {
transform: `translateX(20px)`
},
function Navbar() {
return (
<nav style={styles.nav}>
<div style={styles.wrapper}>
<p className="logo" style={styles.logo}>Hello</p>
</div>
For more on template literals: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals
transform: "translate(-50%, -50%);"and noticed no difference in styling until I noticed this has been cause by the;