簡體   English   中英

React-Bootstrap:復選框左側的標簽

[英]React-Bootstrap: Label on the left side of checkbox

我以這種方式使用 React-Bootstrap 庫中的復選框:

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

我想在左側有一個標簽。 我怎樣才能做到這一點 ?

在有人與我分享這個問題之前,已經在另一篇文章中回答了這個問題。

我使用 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:這里

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

我有同樣的問題。

我的解決方法是不使用 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>

我意識到我還沒有回答你的確切問題。 希望有人有真正的答案。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM