如何将ReactJS-bootstrap表单和h1标签并排放置

时间:2018-07-05 20:19:08

标签: javascript css reactjs react-bootstrap

我想将FormGroup和h1标签水平并排放置。我试过使用display:inline-block和其他各种东西,但是没有运气。这是我的.css代码:

.testingForm {
  max-width: 320px;
}

.testingMore {
  text-align: left;
  float: right;
}

这是.js代码:

<div className="testingForm">
  <FormGroup
    controlId="stuff"
    bsSize="large"
  >
    <ControlLabel>Stuff</ControlLabel>
    <FormControl
    />
  </FormGroup>
</div>
<div className="testingMore">
  <h1>Additional Stuff</h1>
</div>

1 个答案:

答案 0 :(得分:1)

您可以创建一个同时包裹表单和标头的元素,并使用flex将其放入display:flex;容器中

.form-wrapper {
  display: flex;
}

.testingForm {
  max-width: 320px;
}

h1 {
  margin-top: 0;
}
<div class="form-wrapper">
  <div className="testingForm">
    <form>
      Test: <input type="text"/>
    </form>
  </div>
  <div>
    <h1>Additional Stuff</h1>
  </div>
</div>