<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;
}
如何将.search-btn的边框与.form-control相同,因为我专注于.form-control类? 当我专注于输入字段时,我想制作输入字段的边框颜色和搜索按钮#fd9128。
答案 0 :(得分:1)
使用以下代码
.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>
`
答案 1 :(得分:0)
.search-form:focus .search-btn {
border-radius: 30px 0px 0px 30px;
border: 1px solid #ffffff;
border-right: 0px;
}
答案 2 :(得分:0)
在按钮
中添加此css以进行焦点.search-form:focus + .input-group-btn button{
background: transparent;
border-color: #66afe9;
color: #66afe9;
box-shadow: inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6);
}
.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;
}
.search-form:focus + .input-group-btn button{
background: transparent;
border-color: #66afe9;
color: #66afe9;
box-shadow: inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6);
}
&#13;
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" ></script>
<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>
&#13;