【问题标题】:how to give margin to a functional component in react.js?如何为 react.js 中的功能组件留出余量?
【发布时间】:2021-06-12 12:24:14
【问题描述】:

这是我的功能组件返回的代码:

return (

    <div className="card border-0 shadow " >
      <div className="card-header">Update a Book</div>
      <div className="card-body">
        <form onSubmit={(e) => onUpdateContact(e)}>
          <div className="form-group">
        
            <TextField
            id="outlined-helperText"
            label="Enter The Name"
            defaultValue={n}
            onChange={(e) => setName(e.target.value)}
            variant="outlined"
            
          />
          </div>
          <div className="form-group">
           
            <TextField
            id="outlined-helperText"
            label="Enter The Isbn"
            defaultValue={isb}
            onChange={(e) => setIsbn(e.target.value)}
            variant="outlined"
            
          />
          </div>
      
         
          <button className="btn btn-warning" type="submit">
            Update Book
          </button>
        </form>
      </div>
    </div>

  );

我想给它左右边距....怎么做?当我在&lt;div className="card border-0 shadow " &gt; 中输入边距作为属性时,它给出了错误

错误:

<div className="card border-0 shadow " margin=20px >

【问题讨论】:

标签: javascript html css reactjs


【解决方案1】:

这就是你需要的

<div style={{margin: '0 20px'}}>
...Your content
</div>

【讨论】:

    【解决方案2】:

    你可以使用style属性:

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

    或者您可以通过 CSS 添加边距:

    .card {
       margin: 20px;
    }
    

    【讨论】:

      猜你喜欢
      • 2019-12-07
      • 1970-01-01
      • 2018-10-15
      • 1970-01-01
      • 2021-06-12
      • 2013-01-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多