<form class="navbar-form" >
            <div class="input-group">
              <input type="text" class="form-control search-form" placeholder="Search">
               <span class="input-group-btn"><button type="submit" class="btn btn-primary search-btn"><i class="fa fa-search"></i>
                </button></span>
            </div>
        </form>


.search-form {
border-radius: 30px 0px 0px 30px;
background-color: transparent;
border: 1px solid #ffffff;
border-right: 0px;
}
.search-btn {
border-radius: 0px 30px 30px 0px;
cursor:pointer;
background-color: transparent;
border: 1px solid #ffffff;
border-left: 0px;
}


我专注于.form-control类时,如何使.search-btn的边框与.form-control相同?
我想在关注输入字段时使输入字段和搜索按钮#fd9128的边框颜色。

最佳答案

使用下面的代码



.search-form {
border-radius: 30px 0px 0px 30px;
background-color: transparent;
border: 1px solid #ffffff;
border-right: 0px;
}
.search-btn {
border-radius: 0px 30px 30px 0px;
cursor:pointer;
background-color: transparent;
border: 1px solid #ffffff;
border-left: 0px;
  color:blue
}
.search-form:focus ~span .search-btn{
    border-color: #66afe9;
    outline: 0;
    -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102,175,233,.6);
    box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102,175,233,.6);
}

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
  <title>JS Bin</title>
</head>
<body>
   <form class="navbar-form" >
     <div class="input-group">
       <input type="text" class="form-control search-form" placeholder="Search">
       <span class="input-group-btn"><button type="submit" class="btn btn-primary search-btn"><i class="fa fa-search">Submit</i>
         </button></span>
     </div>
  </form>
</body>
</html>





`

关于html - 当我关注一个类(class)时,如何更改另一个类(class)的边界?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/47385276/

10-12 14:09