减少标签的可点击区域

时间:2018-02-06 15:12:21

标签: html css twitter-bootstrap-3

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

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

我尝试将标签类设为inline。但是单选按钮排列在一起 线。

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

这是我的代码:

&#13;
&#13;
    <!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>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

像这样的东西可以用于桌面:

<!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>

:查看整页。

相关问题