I want to use max-width in a React component. I tried both max-width
and maxWidth
attributes , but it looks like that it's omitted from the element when I inspect it.
(When I put it in the CSS it works.)
You need to use the style
attribute. See Inline Styles.
<div style={{ maxWidth: 250 }}></div>
You must have copied the code from somewhere else so, please check the if there is ";" semicolon inside inline styling, because react doesn't support that. Use syntax like the following:
<div style={{maxWidth: "100px"}}></div>
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