0

我正在尝试更改默认的 Bootstrap 表单样式以获得类似图片显示的表单样式(只是一个下划线) 形式

但是,我无法删除 Bootstrap 表单具有的默认灰色边框。我怎样才能删除它。(请在此帖子中找到代码)

综上所述,我想保留红色底线并删除我的代码的灰色线。

谢谢

.form-control {
    background-color: transparent !important;
    background-image: none !important;
	border-bottom-color:red !important;
	border-bottom-style:solid !important;
	border-bottom-width:1px !important;
	
    border-radius: 0 !important;
    box-shadow: 0 !important;
    display: block !important;
    font-size: 15px !important;
    height: 45px !important;
    line-height:  1!important;
    padding: 5px 20px 20px 14px;
    width: 100%;
}
<!doctype html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
  </head>
<body>
<!-- form -->
<div class="container"> 
<div class="row">
	
    <div style="margin-top:70px; padding-right:26px; padding-left:78px " class="col-md-6 mb_40">
    
<form  class="form-horizontal">
<fieldset>


<!-- Name input-->
<div class="form-group row">
  <div class="col-md-6">
  <input id="Name" name="Name" type="text" placeholder="Name" class="form-control input-md" required="">
  </div>
<!-- Email input-->
  <div class="col-md-6">
  <input id="email" name="email" type="text" placeholder="Email" class="form-control input-md" required="">
  </div>
</div>

<!-- Subject input-->
<div class="form-group">
  <div class="col-md-12">
  <input id="Subject" name="Subject" type="text" placeholder="Subject" class="form-control input-md" required="">
  </div>
</div>

<!-- Textarea -->
<div class="form-group">
  <div class="col-md-12">                     
    <textarea class="form-control" id="Message" name="Message">Message</textarea>
  </div>
</div>

</fieldset>
<div class="col-md-12">
<div class="row">
<button style="padding-right:20px; padding-left:20px" type="submit" class="btn btn-black">Send</button>
<div class="g-recaptcha pull-right" data-sitekey="6Le_VicTAAAAAN1XKkiFpdQGDugyzdALXKEnBSaz"></div>
</div>
</div>
</form>

	</div>
    
</div>
</div>
<!-- /.form--></body>
</html>

4

3 回答 3

2

将以下 css 添加到表单控制边框:solid 1px red !important; 边框宽度:0 0 1px 0 !重要;

.form-control {
    border: solid 1px red !important;
    border-width: 0 0 1px 0 !important;
    background-color: transparent !important;
    background-image: none !important;
	
    border-radius: 0 !important;
    box-shadow: 0 !important;
    display: block !important;
    font-size: 15px !important;
    height: 45px !important;
    line-height:  1!important;
    padding: 5px 20px 20px 14px;
    width: 100%;
    box-shadow: none !important;
}
<!doctype html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
  </head>
<body>
<!-- form -->
<div class="container"> 
<div class="row">
	
    <div style="margin-top:70px; padding-right:26px; padding-left:78px " class="col-md-6 mb_40">
    
<form  class="form-horizontal">
<fieldset>


<!-- Name input-->
<div class="form-group row">
  <div class="col-md-6">
  <input id="Name" name="Name" type="text" placeholder="Name" class="form-control input-md" required="">
  </div>
<!-- Email input-->
  <div class="col-md-6">
  <input id="email" name="email" type="text" placeholder="Email" class="form-control input-md" required="">
  </div>
</div>

<!-- Subject input-->
<div class="form-group">
  <div class="col-md-12">
  <input id="Subject" name="Subject" type="text" placeholder="Subject" class="form-control input-md" required="">
  </div>
</div>

<!-- Textarea -->
<div class="form-group">
  <div class="col-md-12">                     
    <textarea class="form-control" id="Message" name="Message">Message</textarea>
  </div>
</div>

</fieldset>
<div class="col-md-12">
<div class="row">
<button style="padding-right:20px; padding-left:20px" type="submit" class="btn btn-black">Send</button>
<div class="g-recaptcha pull-right" data-sitekey="6Le_VicTAAAAAN1XKkiFpdQGDugyzdALXKEnBSaz"></div>
</div>
</div>
</form>

	</div>
    
</div>
</div>
<!-- /.form--></body>
</html>

于 2016-08-12T09:06:41.780 回答
1

**方法一:直接更新引导类**

.form-control
{
  border:none !important
}
于 2016-08-12T09:03:28.583 回答
1

设置Border:0px然后设置Border-bottom-width。这就是你所需要的。

.form-control {
  background-color: transparent !important;
  border: 0px solid !important;
  border-radius: 0 !important;
  background-image: none !important;
  border-bottom-color: red !important;
  border-bottom-style: solid !important;
  border-bottom-width: 1px !important;
  box-shadow: none !important;
  display: block !important;
  font-size: 15px !important;
  height: 45px !important;
  line-height: 1!important;
  padding: 5px 20px 20px 14px;
  width: 100%;
}
<!doctype html>
<html lang="en">

<head>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>

<body>
  <!-- form -->
  <div class="container">
    <div class="row">

      <div style="margin-top:70px; padding-right:26px; padding-left:78px " class="col-md-6 mb_40">

        <form class="form-horizontal">
          <fieldset>


            <!-- Name input-->
            <div class="form-group row">
              <div class="col-md-6">
                <input id="Name" name="Name" type="text" placeholder="Name" class="form-control input-md" required="">
              </div>
              <!-- Email input-->
              <div class="col-md-6">
                <input id="email" name="email" type="text" placeholder="Email" class="form-control input-md" required="">
              </div>
            </div>

            <!-- Subject input-->
            <div class="form-group">
              <div class="col-md-12">
                <input id="Subject" name="Subject" type="text" placeholder="Subject" class="form-control input-md" required="">
              </div>
            </div>

            <!-- Textarea -->
            <div class="form-group">
              <div class="col-md-12">
                <textarea class="form-control" id="Message" name="Message">Message</textarea>
              </div>
            </div>

          </fieldset>
          <div class="col-md-12">
            <div class="row">
              <button style="padding-right:20px; padding-left:20px" type="submit" class="btn btn-black">Send</button>
              <div class="g-recaptcha pull-right" data-sitekey="6Le_VicTAAAAAN1XKkiFpdQGDugyzdALXKEnBSaz"></div>
            </div>
          </div>
        </form>

      </div>

    </div>
  </div>
  <!-- /.form-->
</body>

</html>

于 2016-08-12T09:04:40.843 回答