通过覆盖样式道具让 material-ui 组件内联显示

Getting material-ui components to appear inline by overriding style props

我正在尝试让一个复选框出现在输入字段的右侧 "answer input one" 我试过使用显示 属性 但我真的很难使用 css 布局一般。what I am currently getting

这是呈现答案输入的代码:

     <div>
  <TextField
  hintText="An informative question title..."
  fullWidth
  floatingLabelText="Question Title"
  value={questionTitle}
  onChange={(e) => this.props.questionTitleChanged(e.target.value)}
  />
  <TextField
  floatingLabelText="Answer Input 1"
  onChange={(e) => this.props.questionInputChanged({
    inputIndex: 0,
    value: e.target.value,
    correct: false
  })}
  value={questionInputs[0].value}
  style={styles.answerField}
  />

  <Checkbox
  onCheck={() => {
    let correctOrIncorrect = null;

    if (questionInputs[0].correct) {
      correctOrIncorrect = false;
    } else { correctOrIncorrect = true; }

    this.props.questionInputChanged({
    inputIndex: 0,
    value: null,
    correct: correctOrIncorrect });
  }}
  style={styles.checkbox}
  />

  </div>

内联样式在这里:

const styles = {
  createQuizContainer: {
    width: '70%',
    margin: 'auto',
    paddingTop: 30,
    paddingBottom: 40
  },
  answerField: {
    width: '70%',
  },
  checkBox: {
    display: 'inline',
  }

};

非常感谢您的帮助!以及关于 css 一般布局的任何建议!

谢谢。

我将复选框的 css 更改为:

checkbox: {
    float: 'right',
    width: '10%',
    marginTop: '7%'
  }

原样是以前的全角。这不是一个很好的解决方案,但无论如何都能解决

你可以使用 flexbox:

render() {
    return (
        <div style={{ display: 'inline-flex' }}>
            <div>
                <TextField />
            </div>
            <div style={{ alignSelf: 'center' }}>
                <Checkbox />
            </div>
        </div>
    );
}

https://jsfiddle.net/2v1Legy2/1/