【问题标题】:Radio buttons dropping text below radio button单选按钮将文本放在单选按钮下方
【发布时间】:2019-04-23 03:49:09
【问题描述】:

我正在使用 Bootstrap v3.3.0,但我的单选按钮有问题。

问题是任何带有长文本的东西都会将文本放在单选按钮下方,而不是仅仅在第一行下方换行。在宽屏显示器上全屏显示它看起来不错。但是随着尺寸变小,它看起来很糟糕。我认为引导程序会自动为您自动换行。

我是否以错误的方式使用引导程序?

<div class="row">
    <div class="col-lg-12">
        <div class="form-group">
            <input id="Valid-Driver-License" name="residenceProof" type="radio" required value="#form.FLDL#" />
            <label for="Valid-Driver-License">A valid driver license or ID card with photo issued by any US state or territory (Florida driver license must indicate a Manatee County address)</label>
        </div>
    </div>
</div>

<div class="row">
    <div class="col-lg-12">
        <div class="form-group">
            <input id="Canadian-Driver-License" name="residenceProof" type="radio" required value="#form.Canadian#" />
            <label for="Canadian-Driver-License">A Canadian driver license or ID card </label>
        </div>
    </div>
</div>

<div class="row">
    <div class="col-lg-12">
        <div class="form-group">
            <input id="Valid-Passport" name="residenceProof" type="radio" required value="#form.Passport#" />
            <label for="Valid-Passport">A valid US or out-of-country passport</label>
        </div>
    </div>
</div>

<div class="row">
    <div class="col-lg-12">
        <div class="form-group">
            <input id="Power-Of-Attorney-Copy" name="residenceProof" type="radio" required  value="#form.POA#" />
            <label for="Power-Of-Attorney-Copy">If transaction is being completed by <a href="https://www.powerdms.com/public/MCTC/documents/1474142" target="_blank">Power of Attorney</a> a copy of the valid driver license, identification card or passport for both the applicant <font color="red">and</font> the person appointed power of attorney is required. <font color="red">If the Power of Attorney appoints a business/dealership alone or with an individual, the business/dealership must include a letter of authorization on their letterhead stating that the person who is signing by power of attorney on their behalf is authorized to do so.</font></label>
        </div>
    </div>
</div>

【问题讨论】:

    标签: html twitter-bootstrap twitter-bootstrap-3


    【解决方案1】:

    您可以尝试的一件事是将input 放在label 标记内;这样文本将换行并在新行中继续,但第一个将始终留在输入的一侧。

    .example-2 {
      display: flex;
    }
    <link href="https://stackpath.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
    <div class="row">
      <div class="col-lg-12">
        <div class="form-group">
          <label for="Valid-Driver-License">
           <input id="Valid-Driver-License" name="residenceProof" type="radio" required value="#form.FLDL#" />
          A valid driver license or ID card with photo issued by any US state or territory (Florida driver license must indicate a Manatee County address)</label>
        </div>
      </div>
    </div>
    
    <div class="row">
      <div class="col-lg-12">
        <div class="form-group">
          <input id="Canadian-Driver-License" name="residenceProof" type="radio" required value="#form.Canadian#" />
          <label for="Canadian-Driver-License">A Canadian driver license or ID card </label>
        </div>
      </div>
    </div>
    
    <div class="row">
      <div class="col-lg-12">
        <div class="form-group">
          <input id="Valid-Passport" name="residenceProof" type="radio" required value="#form.Passport#" />
          <label for="Valid-Passport">A valid US or out-of-country passport</label>
        </div>
      </div>
    </div>
    
    <div class="row">
      <div class="col-lg-12">
        <div class="form-group">
          <label for="Power-Of-Attorney-Copy">
          <input id="Power-Of-Attorney-Copy" name="residenceProof" type="radio" required value="#form.POA#" />
          If transaction is being completed by <a href="https://www.powerdms.com/public/MCTC/documents/1474142" target="_blank">Power of Attorney</a> a copy of the valid driver license, identification card or passport for both the applicant <font color="red">and</font> the person appointed power of attorney is required. <font color="red">If the Power of Attorney appoints a business/dealership alone or with an individual, the business/dealership must include a letter of authorization on their letterhead stating that the person who is signing by power of attorney on their behalf is authorized to do so.</font></label>
        </div>
      </div>
    
    </div>
    
    
    <!-- New Example -->
    <div class="row">
      <div class="col-lg-12">
        <div class="form-group example-2">
          <input id="Power-Of-Attorney-Copy" name="residenceProof" type="radio" required value="#form.POA#" />
          <label for="Power-Of-Attorney-Copy">
          If transaction is being completed by <a href="https://www.powerdms.com/public/MCTC/documents/1474142" target="_blank">Power of Attorney</a> a copy of the valid driver license, identification card or passport for both the applicant <font color="red">and</font> the person appointed power of attorney is required. <font color="red">If the Power of Attorney appoints a business/dealership alone or with an individual, the business/dealership must include a letter of authorization on their letterhead stating that the person who is signing by power of attorney on their behalf is authorized to do so.</font></label>
        </div>
      </div>
    </div>

    【讨论】:

    • 这非常接近,但最后一个项目符号包裹在单选按钮下方,它是否能够包裹在第一行文本开始的下方?让它整齐排列?
    • @DavidBrierton 绝对是,IMO 最简单的方法就是让这两个元素的父元素成为一个 flex-container,(记得先把 input 从 label 中取出)这样您可以在列或行中对齐项目,再次检查答案,最后一个项目符号......现在,Flexbox 非常强大,并且 Bootstrap v4 都是基于 flexbox 构建的,所以如果可能的话,我建议从 v3 更改为 v4 :)
    • 当我添加行时,您将行删除,它会将文本放在项目符号下方
    • 行无所谓,可以加也可以去掉,重要的是输入和标签的容器是flex容器,再检查一下,我都包在一行里面,它看起来还是一样
    • @DavidBrierton 你能解决它吗?
    【解决方案2】:

    你需要把标签放在标签里面。

    <label for="Power-Of-Attorney-Copy">
        <input id="Power-Of-Attorney-Copy" name="residenceProof" type="radio" required  value="#form.POA#" />
           If transaction is being completed by <a href="https://www.powerdms.com/public/MCTC/documents/1474142" target="_blank"> Power of Attorney</a> a copy of the valid driver license, identification card or passport for both the applicant <font color="red">and</font> the person appointed power of attorney is required. <font color="red">If the Power of Attorney appoints a business/dealership alone or with an individual, the business/dealership must include a letter of authorization on their letterhead stating that the person who is signing by power of attorney on their behalf is authorized to do so.</font>
    </label>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-12-28
      • 1970-01-01
      • 1970-01-01
      • 2013-10-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多