jam*_*mes -1 html javascript css jquery twitter-bootstrap
我可以在 Bootstrap 3 中轻松创建导航搜索栏。但我想构建与Google Developers搜索栏非常相似的东西。
我当然可以尝试查看 google 的页面并找出与搜索框相关的页面,但是以我目前的 css 技能将永远带我去。
特别是如何在 Bootstrap 3 中创建具有以下功能的搜索导航栏?

我希望用户可以选择在 HTML 下拉列表中选择一个过滤器,它会在搜索栏中显示为一个标签,如下所示:

在智能手机屏幕上,搜索框将折叠为搜索按钮,单击该按钮后,它将展开类似于 Google Developers 站点。(与菜单的折叠分开)。

我可以处理 JS 部分(使用 angular),我只需要对 css 部分有一个想法。我已经搜索了这个站点(http://tympanus.net/codrops/2010/07/14/ui-elements-search-box/),但我想用已经到位的引导程序类来实现它。
到目前为止,我在 Fizzix 的帮助下获得了以下内容: JSFiddle Demo HTML:
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Brand</a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Others <span class="sr-only">(current)</span></a></li>
<li><a href="#">Categories</a></li>
</ul>
<form class="navbar-form navbar-left" role="search">
<div class="search-box">
<input value="Search" type="text" class="form-control" />
<i class="glyphicon glyphicon-search"></i>
</div>
</form>
<ul class="nav navbar-nav navbar-right">
<li><a href="#">Link</a></li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
Run Code Online (Sandbox Code Playgroud)
CSS:
body {
margin: 20px;
background: #455a64;
}
.search-box {
position: relative;
}
.search-box .glyphicon {
position: absolute;
padding: 10px;
pointer-events: none;
left: 15px;
top: 0px;
}
.search-box .glyphicon:before {
color: white;
transition: all 0.2s linear;
}
.search-box input {
color: #fff;
padding-left: 60px;
background: #546e7a;
border:0;
outline: none !important;
transition: all 0.2s linear;
}
.search-box input:focus {
background: #fff !important;
outline: 0;
color: #333;
}
.search-box input:focus + .glyphicon:before {
color: #333;
}
.search-box input:hover {
background: #78909c;
}
Run Code Online (Sandbox Code Playgroud)
您的问题很可能会被关闭,因为您还没有尝试自己先做这件事,而且您基本上是在要求我们在没有任何尝试的情况下完成所有艰苦的工作
我试图模仿大多数风格,尽管placeholder颜色是棘手的部分。相反,我将 的值添加Search到输入并设置颜色样式。您可以通过 Angular 处理占位符部分。
不幸的是,我现在时间紧张,无法让下拉菜单处理focus.
如果您想了解 CSS 的完整细分,请告诉我,我可以与您一起逐步完成。
CSS:
.search-box {
position: relative;
}
.search-box .glyphicon {
position: absolute;
padding: 10px;
pointer-events: none;
left: 15px;
top: 0px;
}
.search-box .glyphicon:before {
color: white;
transition: all 0.2s linear;
}
.search-box input {
color: #fff;
padding-left: 60px;
background: #546e7a;
border:0;
outline: none !important;
transition: all 0.2s linear;
}
.search-box input:focus {
background: #fff !important;
outline: 0;
color: #333;
}
.search-box input:focus + .glyphicon:before {
color: #333;
}
.search-box input:hover {
background: #78909c;
}
Run Code Online (Sandbox Code Playgroud)
HTML:
<div class="search-box">
<input value="Search" type="text" class="form-control" />
<i class="glyphicon glyphicon-search"></i>
</div>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6061 次 |
| 最近记录: |