【问题标题】:Rails checkbox and label on same lineRails 复选框和标签在同一行
【发布时间】:2017-10-26 02:45:57
【问题描述】:

有人知道如何让复选框和标签对齐吗?

<tr>
  <td>
    <div class="field form-group">
      <%= ff.label :cert_never_expires, 'This certification does not expire' %>
      <%= ff.check_box :cert_never_expires, class: "form-control" %>
    </div>        
  </td>
</tr>

【问题讨论】:

  • 请为field form-groupform-control发布CSS
  • 还没有 CSS。无法让我尝试的任何工作。这些只是现在存在的 Bootstrap。
  • 可以使用css修改。或者你可以在这里举例bootsnipp.com
  • 你在使用 bootstrap css 吗?
  • 是的,我正在使用引导 css

标签: html css ruby-on-rails


【解决方案1】:

你真的需要使用那个 div 吗,我的意思是如果它不是必需的,那么就删除它

<td style="width: 30%">
   <div class="field form-group">
   <%= ff.label :cert_never_expires, 'This certification does not expire' %>
   <%= ff.check_box :cert_never_expires, class: "form-control" %>
   </div>
 </td>

【讨论】:

  • 使用内联“样式”是一种不好的做法,请使用 CSS 设置元素样式。
【解决方案2】:

搞定了

<div>
  <%= ff.label :cert_never_expires, "This certification does not expire", class: "l" %>
  <%= ff.check_box :cert_never_expires, class: 'cb' %>
</div>

这是 CSS

  .cb {
    text-align: center;    
    width: 5%;
    transform: scale(1.2);
  }  

 .l {
     padding-right: 5px;
 }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-09-18
    • 1970-01-01
    • 1970-01-01
    • 2019-01-26
    • 1970-01-01
    • 1970-01-01
    • 2019-03-09
    相关资源
    最近更新 更多