7

我以这种方式使用 React-Bootstrap 库中的复选框:

var checkBtn = ce(bootstrap.Input, {type: "checkbox", label: "Multiplied ",
checked: this.isChecked, id: "multBtn", onClick: this.onChange });

我想在左侧有一个标签。我怎样才能做到这一点 ?

4

2 回答 2

1

在有人与我分享这个问题之前,已经在另一篇文章中回答了这个问题。

我使用 flex 通过改变行方向来解决这个问题。

HTML:

<div class="checkbox">
    <label title="">
        <input type="checkbox" value="">
        Did not perform
    </label>
</div>

CSS:

div.checkbox {
  display: inline-block;
  /*ie7 -- start*/
  *display: inline;
  zoom: 1;
}

div.checkbox > label {
  display: flex;
  flex-direction: row-reverse;
}

输出:

在此处输入图像描述

JSFiddle:这里

你可以在这里找到我的原始帖子/答案

于 2018-11-02T14:15:05.437 回答
0

我有同样的问题。

我的解决方法是不使用 react-bootstrap(使用 jsx 的示例):

<div className={'form-group'}>
  <label
    className={'control-label'}
    htmlFor={fieldName}
  >
    {fieldName + ':'}
  </label>
  <input
    type='checkbox'
    id={fieldName}
    name={fieldName}
    checked={fieldValue}
  />
</div>

我意识到我没有回答你的确切问题。希望有人有真正的答案。

于 2015-10-01T11:24:06.277 回答