html - 与表单控件类相关的类在 bootstrap 4 中无法正常运行

标签 html css bootstrap-4

1) form input 元素的边框颜色不会更改为绿色、橙色或红色等相关颜色。

2) 它不会在输入的正确位置插入相关的 gif,如“ok”或“x”gif。

我期望 form-control-success 或 form-control-warning 或 form-control-danger 会起作用,但它没有。为什么?

<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />

<div class="form-group">
  <label class="form-control-label text-success" for="inputSuccess2">
            Success
        </label>
  <input type="text" class="form-control form-control-success" id="inputSuccess2" aria-describedby="inputSuccess2Status">
</div>
<div class="form-group">
  <label class="form-control-label text-warning" for="inputWarning2">
            With Warning
        </label>
  <input type="text" class="form-control form-control-warning" id="inputWarning2" aria-describedby="inputWarning2Status">
</div>
<div class="form-group">
  <label class="form-control-label text-danger" for="inputError2">With Error</label>
  <input type="text" class="form-control form-control-danger" id="inputError2" aria-describedby="inputError2Status">
</div>

编辑:

这解决了我的问题。[链接][1]

[1]: Bootstrap 4 form input with icon for validation 强文本

最佳答案

1) Bootstrap 4中没有指定.form-control-success, .form-control-danger等类,你可以自己添加样式表,例如:

.form-control.form-control-success:focus{
   border-color: #28a745;
   box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
}

2) 要在输入中插入 gif,您需要进一步自定义 html/css/js。从这里开始:https://getbootstrap.com/docs/4.3/components/input-group/#custom-forms

关于html - 与表单控件类相关的类在 bootstrap 4 中无法正常运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56260920/

相关文章:

javascript - 检查是否支持占位符的简单方法?

javascript - 根据 iframe 的内容动态调整其大小

html - CSS3 逗号分隔列表(nth-of-class)

html - 如何使用 Font Awesome 图标在另一个之上

html - Bootstrap Navbar 的颜色不会改变

css - Bootstrap 4 中的 '.well' 等效类是什么

html - 在 id 中选择一个类

javascript - 如何使用 jquery 将鼠标悬停在不同的元素上。

css - 多个标签来切换复选框

php - 用于视差背景的图像是从 http 本地主机而不是 style.css 中的 wordpress url 中提取的