Apple.com搜索式转换
Apple.com Search like Transitions
我想让我的搜索栏像Apple.com一样转换,我已经在网上读过很多关于它的帖子。我目前正在使用CSS隐藏和显示元素来创建搜索栏。但搜索栏轮廓和搜索栏背景(白色)仍在显示。除了搜索字形图标(就像apple.com一样),我什么都不想显示。这有点困难,因为字形图标显示为输入框内的背景图像。
我需要JS来完全实现行为吗?或者有什么方法可以使输入框的其余部分不可见?
HTML:
<input type="text" class="form-control search left rounded" id="search-bar" placeholder="search" ng-model="search.name"></input>
CSS:
.search {
width:360px;
position:relative; top:2px;
padding:8px 5px 8px 30px;
border:1px solid #ccc;
background:white url(http://i.imgur.com/lFkqn.png) left center no-repeat;
}
#search input {
/*background: none;*/
/*opacity: 0.1;*/
width: 30px !important;
-moz-transition: width 0.5s ease-out !important;
-webkit-transition: width 0.5s ease-out !important;
transition: width 0.5s ease-out !important;
border: 0 !important;
outline: 0 !important;
-webkit-appearance:none !important;
-moz-appearance:none !important;
appearance:none !important;
}
#search input:focus {
/*opacity: 0.9;*/
width: 200px !important;
-moz-transition: width 0.5s ease-out !important;
-webkit-transition: width 0.5s ease-out !important;
transition: width 0.5s ease-out !important;
border: default !important;
background: default !important;
}
以下是您只需要css3的内容。
.search {
width:30px;
position:relative;
top:2px;
padding:8px 5px 8px 30px;
border:1px solid #ccc;
background:white url(http://i.imgur.com/lFkqn.png) left center no-repeat;
-moz-transition: width 0.5s linear !important;
-webkit-transition: width 0.5s linear !important;
transition: width 0.5s ease-in-out !important;
}
#search input {
/*background: none;*/
/*opacity: 0.1;*/
width: 30px !important;
-moz-transition: width 0.5s ease-out !important;
-webkit-transition: width 0.5s ease-out !important;
transition: width 0.5s ease-out !important;
border: 0 !important;
outline: 0 !important;
-webkit-appearance:none !important;
-moz-appearance:none !important;
appearance:none !important;
}
.search:focus {
/*opacity: 0.9;*/
width: 200px !important;
-moz-transition: width 0.5s ease-in-out !important;
-webkit-transition: width 0.5s ease-in-out !important;
transition: width 0.5s ease-in-out !important;
border: default !important;
background: default !important;
}
<input type="text" class="form-control search left rounded" id="search-bar" placeholder="search" ng-model="search.name"></input>
<!doctype html>
<html>
<head>
<title>example</title>
<style type="text/css">
body{
background-color: #fff;
}
.search input.search-text{
height: 30px;
border: 0;
color: #555;
margin: 0 auto;
width:25px;
background:white url(http://i.imgur.com/lFkqn.png) left center no-repeat;
transition: width 700ms ,background 700ms;
-webkit-transition: width 700ms ,background 700ms;
-moz-transition: width 700ms ,background 700ms;
-ms-transition: width 700ms ,background 700ms;
-o-transition: width 700ms ,background 700ms;
box-shadow: inset 0 1px 1px #444;
-webkit-box-shadow: inset 0 1px 1px #444;
-moz-box-shadow: inset 0 1px 1px #444;
-ms-box-shadow: inset 0 1px 1px #444;
-o-box-shadow: inset 0 1px 1px #444;
}
.search input.search-text:focus{
background-color: #e1f0f3;
width:450px;
}
</style>
</head>
<body>
<center>
<div class="search">
<input class="search-text" type="text" />
</div>
</center>
</body>
</html>
相关文章:
- 如何在JavaScript中将字符串转换为函数引用
- 用程序搜索JQuery数据表中的文本
- 如何在Javascript中将JSon对象转换为数组
- 使用JS将数组转换为json对象
- 如何使用json将对象列表从java转换为javascript
- 在html Select中添加搜索
- 偶尔结结巴巴地说“;堆叠的”;translate()上的转换(v4.0.0-alpha40)
- 在 Javascript 中将带有空格的字符串数组转换为小写,然后在 Webkit 中搜索它们失败
- 将html元素转换为字符串Javascript(使用搜索获得,而不是内部/外部html)
- 用于转换<李>行转换为搜索链接
- Apple.com搜索式转换
- 将searchlogic的搜索功能转换为transakrails 3
- 使用局部视图将单击搜索转换为即时搜索
- Google电子表格——在使用ImportXML()将Google搜索结果导入单元格后,转换单元格值,Google将ur
- 如何将“media.setVolume”功能转换为进度条或搜索栏
- 过滤ng-repeat基于搜索输入与转换过滤器
- 是否有可能搜索一个布尔在蒙古与ajax帖子没有服务器端转换
- 如何将XML数据转换为要搜索的表,如下所示
- 将二叉搜索树转换为双链表的算法
- Javascript Unicode转换和搜索