选择输入大于引导程序4中的输入字段

时间:2019-02-13 13:48:54

标签: html css html5 css3 bootstrap-4

我有一个选择字段和两个输入字段,但是选择标签比其他两个要大(请参见图片)。我正在使用Bootstrap 4.3。有人可以帮我把它放大到另一个吗?感谢您的帮助!

这是我的代码:

<div class="container content-center" id="margin">
    <form name="formcalc">
        <div class="form-group row">
            <label for="staticEmail" class="col-sm-2 col-form-label">Output 1</label>
            <select class="col-sm-10 form-control" id="mySelect" onchange="myFunction();setOne();">
                <option value="0">CHF 0</option>
                <option value="75000">CHF 75'000</option>
                <option value="100000">CHF 100'000</option>
            </select>
        </div>
        <fieldset disabled>
            <div class="form-group row">
                <label for="staticEmail" class="col-sm-2 col-form-label">Output 2</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" id="n1" name="txtres" value="CHF " readonly>
                </div>
            </div>
            <div class="form-group row">
                <label for="staticEmail" class="col-sm-2 col-form-label">Output 3</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" id="n2" name="txtres2" value="CHF " readonly>
                </div>
            </div>
        </fieldset>
        <button type="button" class="btn btn-outline-danger" id="toggle" data-toggle="modal"
            data-target="#exampleModal">
            button
        </button>
    </form>
    <hr class="featurette-divider">

    <section class="container">
        <p class="lead" id="demo"></p>
    </section>
</div>

picture

3 个答案:

答案 0 :(得分:1)

不是将col-sm-10放在select元素上,而是将select包裹在<div class="col-sm-10">中-请参见下面的演示:

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.1/css/all.css" />
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js"></script>

<div class="container content-center" id="margin">
  <form name="formcalc">
    <div class="form-group row">
      <label for="staticEmail" class="col-sm-2 col-form-label">Output 1</label>
      <div class="col-sm-10">
        <select class="form-control" id="mySelect" onchange="myFunction();setOne();">
          <option value="0">CHF 0</option>
          <option value="75000">CHF 75'000</option>
          <option value="100000">CHF 100'000</option>
        </select>
      </div>
    </div>
    <fieldset disabled>
      <div class="form-group row">
        <label for="staticEmail" class="col-sm-2 col-form-label">Output 2</label>
        <div class="col-sm-10">
          <input type="text" class="form-control" id="n1" name="txtres" value="CHF " readonly>
        </div>
      </div>
      <div class="form-group row">
        <label for="staticEmail" class="col-sm-2 col-form-label">Output 3</label>
        <div class="col-sm-10">
          <input type="text" class="form-control" id="n2" name="txtres2" value="CHF " readonly>
        </div>
      </div>
    </fieldset>
    <button type="button" class="btn btn-outline-danger" id="toggle" data-toggle="modal" data-target="#exampleModal">
            button
        </button>
  </form>
  <hr class="featurette-divider">

  <section class="container">
    <p class="lead" id="demo"></p>
  </section>
</div>

答案 1 :(得分:0)

<fieldset>元素正在引起其自身的填充。您应该将<select>移到<fieldset>内,给它自己的<fieldset>,或者从输入中删除<fieldset>

答案 2 :(得分:0)

您可以像使用select元素一样进行操作,而不必将其放在div中,就像这样:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.0/css/bootstrap.min.css" integrity="sha384-PDle/QlgIONtM1aqA2Qemk5gPOE7wFq8+Em+G/hmo5Iq0CCmYZLv3fVRDJ4MMwEA" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.0/js/bootstrap.min.js" integrity="sha384-7aThvCh9TypR7fIc2HV4O/nFMVCBwyIUKL8XCtKE+8xgCgl/PQGuFsvShjr74PBp" crossorigin="anonymous"></script>  <title>JS Bin</title>
</head>
<body>
<div class="container content-center" id="margin">
    <form name="formcalc">
        <div class="form-group row">
            <label for="staticEmail" class="col-sm-2 col-form-label">Output 1</label>
            <select class="col-sm-10 form-control" id="mySelect" onchange="myFunction();setOne();">
                <option value="0">CHF 0</option>
                <option value="75000">CHF 75'000</option>
                <option value="100000">CHF 100'000</option>
            </select>
        </div>
        <fieldset disabled>
            <div class="form-group row">
                <label for="staticEmail" class="col-sm-2 col-form-label">Output 2</label>
             
                    <input type="text" class="form-control col-sm-10" id="n1" name="txtres" value="CHF " readonly>
           
            </div>
            <div class="form-group row">
                <label for="staticEmail" class="col-sm-2 col-form-label">Output 3</label>
          
                    <input type="text" class="form-control col-sm-10" id="n2" name="txtres2" value="CHF " readonly>
              
            </div>
        </fieldset>
        <button type="button" class="btn btn-outline-danger" id="toggle" data-toggle="modal"
            data-target="#exampleModal">
            button
        </button>
    </form>
    <hr class="featurette-divider">

    <section class="container">
        <p class="lead" id="demo"></p>
    </section>
</div>
</body>
</html>