React-bootstrap: Reverse checkbox input so the label text comes first

安稳与你 提交于 2019-12-11 15:02:20

问题


I have a checkbox generated by react-bootstrap and it's rendered like a label containing input tag and label title. I want to have it so that the label title comes first.

Checkbox from react-bootstrap:

<Checkbox
   checked={checkedStatus}
   onChange={(e) => this.handleToggle(e, checkBoxValue)}
>{title}</Checkbox>

Rendered HTML:

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

Output:


回答1:


I used flex to solve this by changing the row direction.

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;
}

Output:

JSFiddle: here



来源:https://stackoverflow.com/questions/53118202/react-bootstrap-reverse-checkbox-input-so-the-label-text-comes-first

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!