[英]What is the bootstrap form-control class for?
I'm having trouble wrapping my brain around the strategy for how to use the form-control
class offered by Bootstrap. 我在围绕如何使用Bootstrap提供的
form-control
类的策略时遇到了麻烦。
On one hand I have this rather bland comment from the Bootstrap documentation: 一方面,我从Bootstrap文档中得到了一个相当平淡的评论:
Textual form controls—like inputs, selects, and textareas—are styled with the .form-control class.
文本表单控件(如输入,选择和文本区域)使用.form-control类设置样式。 Included are styles for general appearance, focus state, sizing, and more.
其中包括用于一般外观,焦点状态,大小调整等的样式。
Ref: https://getbootstrap.com/docs/4.0/components/forms/#form-controls 参考: https : //getbootstrap.com/docs/4.0/components/forms/#form-controls
While on the other hand I have rather in-the-weeds code to look at: 另一方面,我要查看杂草中的代码:
.form-control {
display: block;
width: 100%;
height: $input-height;
padding: $input-padding-y $input-padding-x;
// ... 40-some lines elided ...
}
ref: https://github.com/twbs/bootstrap/blob/275cd7f91eed9f4051d85c295e5c14ef08937804/scss/_forms.scss 参考: https : //github.com/twbs/bootstrap/blob/275cd7f91eed9f4051d85c295e5c14ef08937804/scss/_forms.scss
My question: How can I holistically approach modifying existing code or writing new code with form-control
. 我的问题:如何使用
form-control
整体地修改现有代码或编写新代码。
You add that class to text input elements (input, select, textarea), eg <input type="email" class="form-control" value="" placeholder="Your email address" />
This is Bootstrap's way of forcing form elements to look the same. 您将该类添加到文本输入元素(输入,选择,文本区域)中,例如
<input type="email" class="form-control" value="" placeholder="Your email address" />
这是Bootstrap的强制方式表单元素看起来相同。
The CSS is so long because they're accounting for all the differences in how browsers natively render those elements. CSS之所以这么长,是因为它们考虑了浏览器本地呈现这些元素的方式的所有差异。
Bootstrap form-control class is use to make an element fit it container Bootstrap Form-Control类用于使元素适合容器
<div>
<input type='text' class='form-control'>
</div>
div{
width: 400px;
background: gray;
}
Define a .form-control
class again. 再次定义一个
.form-control
类。 It will override properties in existing .form-control
of Bootstrap. 它将覆盖Bootstrap的现有
.form-control
的属性。
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> <style> .form-control { border-radius: unset; } </style> <input class="form-control" type="text" value="Test">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.