Bootstrap:是否可以更改" has-error"线的粗细?

时间:2017-06-02 12:15:50

标签: css twitter-bootstrap

您好我在输入中使用has-error类,如下所示:

<!DOCTYPE html>
<html lang="en">
<head>
  <title></title>
  <meta charset="utf-8">
  <meta input1="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

</head>
<body>

    <form method="post">


      <div class="col-lg-4 col-lg-offset-4 has-error">

        <input type="text" name="input" class="form-control"/>

      </div>

    </form>

</body>

</html>

但是我想增加红色边框的粗细,所以我试着添加这个:

<style>

.has-error{

   line-height:3px;
}

</style>

但它没有效果,所以可以改变这个类的厚度以及如何做到这一点吗?

谢谢

2 个答案:

答案 0 :(得分:1)

line-height不是您要更改的媒体资源,请尝试border-width。您还需要将班级指定为.form-control,否则您的风格将无法应用。

&#13;
&#13;
.has-error .form-control{
   border-width: 3px;
   border-color: blue !important;
}
&#13;
<!DOCTYPE html>
<html lang="en">
<head>
  <title></title>
  <meta charset="utf-8">
  <meta input1="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

</head>
<body>

    <form method="post">


      <div class="col-lg-4 col-lg-offset-4 has-error">

        <input type="text" name="input" class="form-control"/>

      </div>

    </form>

</body>

</html>
&#13;
&#13;
&#13;

希望它有所帮助。

答案 1 :(得分:-1)

line-height与边框粗细无关 - 它设置元素内每行文本的垂直大小。要设置边框的粗细,请使用border-width属性:

.has-error {
   border-width: 3px;
}