使用Bootstrap 3在没有类的情况下将表单CSS应用于所有输入

时间:2014-05-19 03:56:33

标签: css styles twitter-bootstrap-3

如何使用Bootstrap 3并且没有类form-control将相同的样式应用于所有表单元素(input,select,textarea)?

"我想要"使用form-control类。

红色箭头没有CSS = =

enter image description here

3 个答案:

答案 0 :(得分:2)

如果你使用less或sass,你可以扩展 所有输入上的表单控制

对于普通CSS,您可以从表单控件复制样式并粘贴到输入{}

答案 1 :(得分:1)

input:-moz-placeholder, select:-moz-placeholder, textarea:-moz-placeholder {
    color: #999999;
}

input::-moz-placeholder, select::-moz-placeholder, textarea::-moz-placeholder {
    color: #999999;
}

input:-ms-input-placeholder ,select:-ms-input-placeholder, textarea:-ms-input-placeholder {
    color: #999999;
}

input::-webkit-input-placeholder, select::-webkit-input-placeholder, textarea::-webkit-input-placeholder {
    color: #999999;
}

input, select, textarea {
  display: block;
  width: 100%;
  height: 34px;
  padding: 6px 12px;
  font-size: 14px;
  line-height: 1.428571429;
  color: #555555;
  vertical-align: middle;
  background-color: #ffffff;
  border: 1px solid #cccccc;
  border-radius: 4px;
  -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
  -webkit-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
  transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
}

input:focus, select:focus, textarea:focus {
  border-color: #66afe9;
  outline: 0;
  -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6);
  box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6);
}

.input[disabled],
input[readonly] {
  cursor: not-allowed;
  background-color: #eeeeee;
}

textarea {
  height: auto;
}

答案 2 :(得分:0)

input[type = "any"]{background-color: #FFFFFF;background-image: none;border: 1px solid #CCCCCC;border-radius: 4px;box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset;color: #555555;display: block;font-size: 14px;height: 34px;line-height: 1.42857;padding: 6px 12px;transition: border-color 0.15s ease-in-out 0s, box-shadow 0.15s ease-in-out 0s;width: 100%;}input, button, select, textarea {font-family: inherit;font-size: inherit;line-height: inherit;}input {line-height: normal;}button,input, optgroup, select, textarea {color: inherit;font: inherit;margin: 0;}