whats wrong with this line? var firstColStyle = {text-align: right};
This works: var firstColStyle = {width: 70};
Seems to be a odd syntax for styles?? The documentation about this issues is very poor. How to make elements reactive, so I can't use 20% instead of 300px.
With best regards
Gerhard
To use inline styles in React, use the style attribute, which accepts a JavaScript object with camel properties. Example: function MyComponent(){ return <div style={{ color: 'blue', lineHeight : 10, padding: 20 }}> Inline Styled Component</div>
Rule of Thumb. The official React documentation frowns upon the use of inline styling as a primary means of styling projects and recommends the use of the className attribute instead.
Use the spread syntax to combine multiple inline style objects in React, e.g. style={{...style1, ... style2}} . The spread syntax will unpack the key-value pairs of the objects into a final object and the styles will get applied to the element. Copied!
An inline style may be used to apply a unique style for a single element. To use inline styles, add the style attribute to the relevant element. The style attribute can contain any CSS property.
Change firstColStyle to:
var firstColStyle = { textAlign: 'right' }
If you have to set px you can:
var someSize = { width : '2px' }
If percentage:
var otherWidth = { width : ' 10%' }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With