【问题标题】:Reduce the clickable area of the label减少标签的可点击区域
【发布时间】:2018-02-06 15:12:20
【问题描述】:

在下面的示例中,如果我使用<label class="radio"> 作为标签并单击单选按钮的区域,它将扩展到页面的整个宽度。

单击此标签外部(内联标签旁边)仍会触发单选按钮。

我尝试将标签类设为inline。但单选按钮排列在一个单一的 行。

是否有任何其他引导程序class 可用于单选按钮/标签以将它们放在具有固定标签宽度的下一行中?

这是我的代码:

    <!DOCTYPE html>
    <html lang="en">
    <head>
      <title>Bootstrap Example</title>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    </head>
    <body>
    
    <div class="container">
      <h2>Form control: inline radio buttons</h2>
      <p>The form below contains three inline radio buttons:</p>
      <form>
        <label class="radio">
          <input type="radio" name="optradio">Option 1
        </label>
        <label class="radio">
          <input type="radio" name="optradio">Option 2
        </label>
        <label class="radio">
          <input type="radio" name="optradio">Option 3
        </label>
      </form>
    </div>
    
    </body>
    </html>

【问题讨论】:

  • 问题标记为 Boostrap 4,但您引用的是 Bootstrap 3。它是哪个?

标签: html css twitter-bootstrap-3


【解决方案1】:

这样的东西可以在桌面上做:

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
  <h2>Form control: inline radio buttons</h2>
  <p>The form below contains three inline radio buttons:</p>
  <form style="display: grid">
    <label class="radio col-sm-2">
      <input type="radio" name="optradio">Option 1
    </label>
    <label class="radio col-sm-2">
      <input type="radio" name="optradio">Option 2
    </label>
    <label class="radio col-sm-2">
      <input type="radio" name="optradio">Option 3
    </label>
  </form>
</div>

</body>
</html>

:查看整页。

【讨论】:

  • 这不能解决问题
猜你喜欢
  • 2021-10-01
  • 1970-01-01
  • 2022-01-17
  • 2010-11-23
  • 1970-01-01
  • 1970-01-01
  • 2012-06-20
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多