0
<div className="card border-0 shadow " style={{margin: '0 500px' }}>

The above code describes how to add margins to a component ,but why can't it be written like this:

<div className="card border-0 shadow " style={{top-margin: '500px';left-margin : '200px' }}>

3 Answers 3

1

Your style syntax is wrong, replace ; with , to make it a valid object. Also object keys should be in camelCase.

Example:

style={{ marginTop: '500px', marginLeft: '200px' }}

Sign up to request clarification or add additional context in comments.

1 Comment

i am following this link : w3schools.com/css/css_margin.asp ...we have properties named as margin-top margin-right margin-bottom margin-left , but from where have you got this property 'marginTop' ?
0

Because you're writing in JSX syntax which means you need to pass an object to the style attribute/prop. These object keys need to be in camelCase notation. You can use CSS classes and add them in the className name attribute as well or just use styled-components.

1 Comment

Note they don't actually need to be camelCase - kebab-case isn't syntatically valid in JS, so that's out, but they could be e.g. snake_case. They just have to be valid identifiers. Alternatively they can be quoted, "kebab-case" would be fine.
0

you have to write it like this

<div className="card border-0 shadow " style={{marginTo: '500px';left-margin : '200px' }}>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.