首页 > 解决方案 > 引导输入字段方角错误

问题描述

我正在使用注册表构建网站(使用 Bootstrap);应用验证反馈 div 时,每个输入字段的右侧角显示为方形,而不是像左侧那样是圆形的。

这方面的一个例子可以在这里看到:https ://codepen.io/anon/pen/RqVeoL

以及以下:

<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">

    <title>Hello, world!</title>
  </head>
  <body>
    Why does the following input field have rounded corners on the left but square corners on the right?
    <form>
      <div class="input-group">
        <input class="form-control">
        <div class="valid-feedback">
          Pass!
        </div>
        <div class="invalid-feedback">
          Fail!
        </div>
      </div>
    </form>
    This is only the case when specifying valid and invalid feedback divs...
    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <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.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
  </body>
</html>

当然,在输入类中指定 'is-valid' 或 'is-invalid' 之前,验证不会出现,但即便如此,右角仍然是平方的。

我在某个地方犯了错误还是这是一个错误?

标签: twitter-bootstrapbootstrap-4

解决方案


input-group意味着在右侧有一个按钮/附加组件。对于简单的输入,只需使用form-group...

  <div class="form-group">
    <input class="form-control">
    <div class="valid-feedback">
      Pass!
    </div>
    <div class="invalid-feedback">
      Fail!
    </div>
  </div>

https://www.codeply.com/go/o9HXbU3VpC


推荐阅读