<分区>
标签 css bootstrap-4
<分区>
我在 bootstrap 4 文档中看到了这个例子:
https://v4-alpha.getbootstrap.com/components/forms/#validation
<div class="form-group has-success">
<label class="form-control-label" for="inputSuccess1">Input with success</label>
<input type="text" class="form-control form-control-success" id="inputSuccess1">
<div class="form-control-feedback">Success! You've done it.</div>
<small class="form-text text-muted">Example help text that remains unchanged.</small>
</div>
<div class="form-group has-warning">
<label class="form-control-label" for="inputWarning1">Input with warning</label>
<input type="text" class="form-control form-control-warning" id="inputWarning1">
<div class="form-control-feedback">Shucks, check the formatting of that and try again.</div>
<small class="form-text text-muted">Example help text that remains unchanged.</small>
</div>
<div class="form-group has-danger">
<label class="form-control-label" for="inputDanger1">Input with danger</label>
<input type="text" class="form-control form-control-danger" id="inputDanger1">
<div class="form-control-feedback">Sorry, that username's taken. Try another?</div>
<small class="form-text text-muted">Example help text that remains unchanged.</small>
</div>
但是,编辑没有颜色
文档说我必须加载 CSS,但在 CSS 中缺少 has-danger 类
https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css
代替在 bootstrap 3 的 CSS 中,类存在
https://getbootstrap.com/docs/3.3/dist/css/bootstrap.min.css
事实上,如果我使用 bootstrap 3 的 css,编辑内容是彩色的
如何在 bootstrap 4 中使用 has-danger 类? 我需要使用 css 而不是 Sass
最佳答案
类 has-danger 不再用于 bootstrap4(已弃用) 在输入中使用 is-invalid 选择器并在代码中包含 class="invalid-feedback"
<div class="invalid-feedback">
关于css - 如何在 bootstrap 4 css 中实现验证?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49878967/