【发布时间】:2022-03-15 17:03:10
【问题描述】:
我正在使用 bootstrap 3 为 angular 4 应用程序开发网页。
尝试添加一个搜索按钮(右上角/左上角),单击该按钮将在下一行展开。 Refer top right corner search button here.
<div class="row">
<div class="col-xs-3">
<form id="demo-2" style="margin-left: 10px">
<input type="search" placeholder="Search..">
</form>
</div>
</div>
css
input {
outline: none;
}
input[type=search] {
-webkit-appearance: textfield;
-webkit-box-sizing: content-box;
font-family: inherit;
font-size: 100%;
}
input::-webkit-search-decoration,
input[type=search] {
background: #ededed url(https://static.tumblr.com/ftv85bp/MIXmud4tx/search-icon.png) no-repeat 9px center;
border: solid 1px #ccc;
padding: 7px 9px 7px 17px;
width: 55px;
border-radius: 1em;
-webkit-transition: all .5s;
-moz-transition: all .5s;
transition: all .5s;
}
input[type=search]:focus {
width: 170px;
background-color: #fff;
-webkit-box-shadow: 0 0 5px rgba(109,207,246,.5);
-moz-box-shadow: 0 0 5px rgba(109,207,246,.5);
box-shadow: 0 0 5px rgba(109,207,246,.5);
}
#demo-2 input[type=search] {
width: 15px;
padding-left: 10px;
color: transparent;
cursor: pointer;
}
#demo-2 input[type=search]:hover {
background-color: #fff;
}
#demo-2 input[type=search]:focus {
width: 200px;
padding-left: 32px;
color: #000;
background-color: #fff;
cursor: auto;
color: black;
}
#demo-2 input:-moz-placeholder {
color: transparent;
}
#demo-2 input::-webkit-input-placeholder {
color: transparent;
}
这让我搜索栏在同一行展开。我试图获得相同的例子。但他们都在谈论扩大同一行。
注意:对于桌面视图,搜索栏和搜索按钮将位于同一行。 Similar to this。将根据移动视图进行更改。
提前致谢。欢迎提出建议。
【问题讨论】:
标签: html css twitter-bootstrap twitter-bootstrap-3 responsive-design