无论是电商网站,还是媒体网,还是个人博客,每个网站都有属于自己个性化的搜索框。今天小编给大家带来7款基于jquery的动画搜索框。每个搜索框都采用了动画效果,一起看下效果图吧。

在线预览   源码下载

实现的代码。

html代码:

  <h1>
CSS Animated Search Boxes</h1>
<p>
(with occasional help from javascript to assign focus)</p>
<div class="sample one">
<input type="text" name="search" placeholder="search">
<button type="submit" class="btn btn-search fa fa-search">
</button>
</div>
<div class="sample two">
<input type="text" name="search" placeholder="search">
<button type="submit" class="btn btn-search fa fa-search">
</button>
<button type="reset" class="btn btn-reset fa fa-times">
</button>
</div>
<div class="sample three">
<input type="text" name="search" placeholder="search">
<button type="submit" class="btn btn-search">
<i class="fa fa-search fa-flip-horizontal"></i>
</button>
</div>
<div class="sample four">
<input type="text" name="search" placeholder="search">
<button type="submit" class="btn btn-search">
<i class="fa fa-search fa-flip-horizontal"></i>
</button>
<button type="reset" class="btn btn-reset fa fa-times">
</button>
</div>
<div class="sample five">
<input type="text" name="search" placeholder="search">
<button type="submit" class="btn btn-search">
<i class="fa fa-search fa-flip-horizontal"></i>
</button>
</div>
<div class="sample six">
<input type="text" name="search" placeholder="search">
<button type="submit" class="btn btn-search">
<i class="fa fa-search fa-flip-horizontal"></i>
</button>
<button type="reset" class="btn btn-reset fa fa-times">
</button>
</div>
<div class="sample seven">
<input type="text" name="search" placeholder="search">
<button type="submit" class="btn btn-search">
<i class="fa fa-search"></i>
</button>
</div>
<div class="sample eight">
<input type="text" name="search" placeholder="search">
<button type="submit" class="btn btn-search">
<i class="fa fa-search"></i>
</button>
<button type="reset" class="btn btn-reset fa fa-times">
</button>
</div>
<div class="sample nine">
<input type="text" name="search" placeholder="search">
<button type="submit" class="btn btn-search">
<i class="fa fa-search"></i>
</button>
</div>
<div class="sample ten">
<input type="text" name="search" placeholder="search">
<button type="submit" class="btn btn-search">
<i class="fa fa-search"></i>
</button>
<button type="reset" class="btn btn-reset fa fa-times">
</button>
</div>
<div class="sample eleven">
<input type="text" name="search" placeholder="search">
<button type="submit" class="btn btn-search">
<i class="fa fa-search"></i>
</button>
</div>
<div class="sample twelve">
<input type="text" name="search" placeholder="search">
<button type="submit" class="btn btn-search">
<i class="fa fa-search"></i>
</button>
<button type="reset" class="btn btn-reset fa fa-times">
</button>
</div>
<div class="sample thirteen">
<input type="text" name="search" placeholder="search">
<button type="submit" class="btn btn-search">
<i class="fa fa-search"></i>
</button>
</div>
<div class="sample fourteen">
<input type="text" name="search" placeholder="search">
<button type="submit" class="btn btn-search">
<i class="fa fa-search"></i>
</button>
<button type="reset" form="form" class="btn btn-reset fa fa-times">
</button>
</div>

css代码:

  * {
box-sizing: border-box;
} html,
body {
font-size: 12px;
} h1 {
margin: 10px 0 0;
text-align: center;
} p {
margin: 0 0 20px;
text-align: center;
} input {
border: 1px solid #ccc;
font-size: 12px;
height: 30px;
padding: 4px 8px;
position: absolute;
width: 50%;
}
input:focus {
outline: none;
} button {
text-align: center;
}
button:focus {
outline: none;
}
button.btn-search, button.btn-reset {
background: hotpink;
border: none;
height: 30px;
font-size: 12px;
padding: 4px;
position: absolute;
width: 30px;
} .sample {
float: left;
height: 50px;
margin: 0 8%;
position: relative;
width: 34%;
}
.sample.one input, .sample.two input {
border-radius: 15px;
right:;
transition: all .3s ease-in-out;
width: 50%;
}
.sample.one input:focus, .sample.two input:focus {
width: 100%;
}
.sample.one input:focus ~ button.btn-search, .sample.two input:focus ~ button.btn-search {
background: hotpink;
color: #fff;
}
.sample.one input:focus ~ button.btn-reset, .sample.two input:focus ~ button.btn-reset {
right: -22px;
}
.sample.one button, .sample.two button {
transition: all .3s ease-in-out;
}
.sample.one button.btn-search, .sample.two button.btn-search {
background: #ccc;
border-radius: 50%;
height: 26px;
right: 2px;
top: 2px;
transition: all .3s ease-in-out;
width: 26px;
}
.sample.one button.btn-reset, .sample.two button.btn-reset {
background: #fff;
border: 1px solid #ccc;
border-radius: 50%;
font-size: 10px;
height: 20px;
line-height: 20px;
padding:;
right: 5px;
top: 5px;
width: 20px;
z-index: -1;
}
.sample.three, .sample.four {
perspective: 400px;
}
.sample.three input, .sample.four input {
width: 120px;
}
.sample.three input:focus ~ button.btn-search, .sample.four input:focus ~ button.btn-search {
transform: rotateY(180deg);
transition: transform .6s ease-in-out .2s;
}
.sample.three input:focus ~ button.btn-reset, .sample.four input:focus ~ button.btn-reset {
transform: rotateX(0deg) translateY(32px) translateX(2px);
transition: transform .6s ease-in-out .8s;
}
.sample.three button.btn-search, .sample.four button.btn-search {
backface-visibility: visible;
color: #fff;
padding:;
position: relative;
transform: rotateY(0deg);
transform-origin: 121px 0;
transform-style: preserve3d;
transition: transform .6s ease-in-out .2s;
width: 120px;
}
.sample.three button.btn-reset, .sample.four button.btn-reset {
backface-visibility: hidden;
background: #ccc;
transform: rotateX(-180deg) translateY(30px) translateX(2px);
transform-origin: 0 32px;
transform-style: preserve3d;
transition: transform .6s ease-in-out .2s;
width: 120px;
}
.sample.four button.btn-search {
transition: transform .6s ease-in-out .8s;
}
.sample.five, .sample.six {
perspective: 400px;
}
.sample.five input, .sample.six input {
width: 120px;
}
.sample.five input:focus ~ button.btn-search, .sample.six input:focus ~ button.btn-search {
transform: rotateY(180deg) translateX(60px);
transition: all .6s ease-in-out .2s;
width: 60px;
}
.sample.five input:focus ~ button.btn-reset, .sample.six input:focus ~ button.btn-reset {
transform: rotateY(0deg);
transition: all .6s ease-in-out .8s;
}
.sample.five button.btn-search, .sample.six button.btn-search {
backface-visibility: visible;
color: #fff;
padding:;
position: relative;
transform: rotateY(0deg) translateX(0px);
transform-origin: 121px 0;
transform-style: preserve3d;
transition: all .6s ease-in-out .2s;
width: 120px;
}
.sample.five button.btn-reset, .sample.six button.btn-reset {
backface-visibility: hidden;
background: #ccc;
left: 184px;
transform: rotateY(180deg);
transform-origin: left 0;
transform-style: preserve3d;
transition: all .6s ease-in-out .2s;
width: 60px;
}
.sample.six button.btn-search {
transition: all .6s ease-in-out .8s;
}
.sample.seven input, .sample.eight input {
border-right: none;
transition: all .3s ease-in;
width: 120px;
}
.sample.seven input:focus, .sample.eight input:focus {
width: 220px;
}
.sample.seven input:focus ~ button.btn-search, .sample.eight input:focus ~ button.btn-search {
background: hotpink;
border-radius: 0 50% 50% 0;
color: #fff;
left: 220px;
}
.sample.seven input:focus ~ button.btn-reset, .sample.eight input:focus ~ button.btn-reset {
animation: bounceRight .6s;
animation-delay: .2s;
animation-timing-function: cubic-bezier(0.3, 0.2, 1, 0.8);
border-radius: 50%;
color: #fff;
left: 254px;
}
.sample.seven button.btn-search, .sample.eight button.btn-search {
background: #ccc;
left: 120px;
transition: all .3s ease-in;
}
.sample.seven button.btn-reset, .sample.eight button.btn-reset {
background: #000;
height: 20px;
left: 120px;
top: 5px;
transition: all .3s ease-in;
width: 20px;
z-index: -1;
}
.sample.nine input, .sample.ten input {
border-radius: 15px;
transition: all .6s ease-in-out .3s;
width: 120px;
}
.sample.nine input:focus, .sample.ten input:focus {
transition-delay:;
width: 200px;
}
.sample.nine input:focus ~ button, .sample.ten input:focus ~ button {
transform: rotateZ(360deg);
}
.sample.nine input:focus ~ button.btn-search, .sample.ten input:focus ~ button.btn-search {
background: hotpink;
color: #fff;
left: 172px;
transition-delay:;
}
.sample.nine input:focus ~ button.btn-reset, .sample.ten input:focus ~ button.btn-reset {
left: 202px;
transition-delay: .3s;
}
.sample.nine button, .sample.ten button {
transition: all .6s ease-in-out;
}
.sample.nine button.btn-search, .sample.ten button.btn-search {
background: #ccc;
border-radius: 50%;
height: 26px;
left: 92px;
top: 2px;
transition-delay: .3s;
width: 26px;
}
.sample.nine button.btn-reset, .sample.ten button.btn-reset {
background: #fff;
border: 1px solid #ccc;
border-radius: 50%;
font-size: 10px;
height: 20px;
left: 92px;
line-height: 20px;
padding:;
top: 5px;
width: 20px;
z-index: -1;
}
.sample.eleven input, .sample.twelve input {
border-radius: 15px;
transition: all .6s ease-in-out;
width: 120px;
}
.sample.eleven input:focus, .sample.twelve input:focus {
width: 200px;
}
.sample.eleven input:focus ~ button.btn-search, .sample.twelve input:focus ~ button.btn-search {
animation: jumpTowardSearch 1.2s linear;
background: hotpink;
color: #fff;
left: 172px;
}
.sample.eleven input:focus ~ button.btn-reset, .sample.twelve input:focus ~ button.btn-reset {
animation: jumpTowardReset 1.2s linear .4s;
left: 202px;
}
.sample.eleven button, .sample.twelve button {
transition: all .6s ease-in-out;
}
.sample.eleven button.btn-search, .sample.twelve button.btn-search {
background: #ccc;
border-radius: 50%;
height: 26px;
left: 92px;
top: 2px;
width: 26px;
}
.sample.eleven button.btn-reset, .sample.twelve button.btn-reset {
background: #fff;
border: 1px solid #ccc;
border-radius: 50%;
font-size: 10px;
height: 20px;
left: 92px;
line-height: 20px;
padding:;
top: 5px;
width: 20px;
z-index: -1;
}
.sample.thirteen input, .sample.fourteen input {
background: none;
border-color: #000;
border-radius: 15px;
border-width: 0 0 1px;
transition: all .8s ease-in-out;
width: 30px;
}
.sample.thirteen input:focus, .sample.fourteen input:focus {
background: radial-gradient(ellipse at top left, rgba(0, 0, 0, 0) 65%, #ff69b4 140%);
border-radius: 0 15px 15px 0;
width: 250px;
}
.sample.thirteen input:focus ~ button.btn-search, .sample.fourteen input:focus ~ button.btn-search {
background: hotpink;
color: #fff;
left: 222px;
transform: rotate(720deg);
}
.sample.thirteen input:focus ~ button.btn-reset, .sample.fourteen input:focus ~ button.btn-reset {
left: 256px;
transform: rotate(360deg);
}
.sample.thirteen button, .sample.fourteen button {
transition: all .8s ease-in-out;
}
.sample.thirteen button.btn-search, .sample.fourteen button.btn-search {
background: #ccc;
border: 1px solid #000;
border-radius: 50%;
height: 30px;
left:;
width: 30px;
}
.sample.thirteen button.btn-reset, .sample.fourteen button.btn-reset {
background: #fff;
border: 1px solid #ccc;
border-radius: 50%;
font-size: 10px;
height: 20px;
left: 2px;
line-height: 20px;
padding:;
top: 10px;
width: 20px;
z-index: -1;
} @keyframes bounceRight {
0% {
transform: translateX(0px);
}
50% {
transform: translateX(10px);
}
100% {
transform: translateX(0px);
}
}
@keyframes jumpTowardSearch {
0% {
background: #ccc;
opacity:;
transform: rotateZ(0deg) scale(1);
}
20% {
background: #ccc;
opacity:;
transform: rotateZ(-60deg) scale(50);
}
55% {
background: hotpink;
opacity:;
transform: rotateZ(-30deg) scale(100);
}
90% {
background: hotpink;
opacity:;
transform: rotateZ(-30deg) scale(50);
}
100% {
background: hotpink;
opacity:;
transform: rotateZ(0deg) scale(1);
}
}
@keyframes jumpTowardReset {
0% {
opacity:;
transform: rotateZ(0deg) scale(1);
}
20% {
opacity:;
transform: rotateZ(-60deg) scale(50);
}
55% {
opacity:;
transform: rotateZ(-30deg) scale(100);
}
90% {
opacity:;
transform: rotateZ(-30deg) scale(50);
}
100% {
opacity:;
transform: rotateZ(0deg) scale(1);
}
}

js代码:

   $('body')
.on('click', 'div.three button.btn-search', function (event) {
event.preventDefault();
var $input = $('div.three input');
$input.focus();
if ($input.val().length() > 0) {
// submit form
}
})
.on('click', 'div.four button.btn-search', function (event) {
event.preventDefault();
var $input = $('div.four input');
$input.focus();
if ($input.val().length() > 0) {
// submit form
}
})
.on('click', 'div.five button.btn-search', function (event) {
event.preventDefault();
var $input = $('div.five input');
$input.focus();
if ($input.val().length() > 0) {
// submit form
}
})
.on('click', 'div.six button.btn-search', function (event) {
event.preventDefault();
var $input = $('div.six input');
$input.focus();
if ($input.val().length() > 0) {
// submit form
}
})
.on('click', 'div.seven button.btn-search', function (event) {
event.preventDefault();
var $input = $('div.seven input');
$input.focus();
if ($input.val().length() > 0) {
// submit form
}
})
.on('click', 'div.eight button.btn-search', function (event) {
event.preventDefault();
var $input = $('div.eight input');
$input.focus();
if ($input.val().length() > 0) {
// submit form
}
})
.on('click', 'div.thirteen button.btn-search', function (event) {
event.preventDefault();
var $input = $('div.thirteen input');
$input.focus();
if ($input.val().length() > 0) {
// submit form
}
})
.on('click', 'div.fourteen button.btn-search', function (event) {
event.preventDefault();
var $input = $('div.fourteen input');
$input.focus();
if ($input.val().length() > 0) {
// submit form
}
})

注:本文爱编程原创文章,转载请注明原文地址:http://www.w2bc.com/Article/8402

7款基于jquery的动画搜索框的更多相关文章

  1. 基于jQuery select下拉框美化插件

    分享一款基于jQuery select下拉框美化插件.该插件适用浏览器:IE8.360.FireFox.Chrome.Safari.Opera.傲游.搜狗.世界之窗.效果图如下: 在线预览   源码下 ...

  2. 10款基于jquery的web前端动画特效

    1.jQuery横向手风琴图片切换动画 之前我们为大家分享过很多款基于jQuery和CSS3的手风琴菜单和手风琴焦点图插件,比如CSS3响应式垂直手风琴菜单和jQuery横向手风琴图片展示插件.今天要 ...

  3. 10款基于jquery实现的超酷动画源码

    1.jQuery二级下拉菜单 下拉箭头翻转动画 之前我们分享过不少基于jQuery的二级下拉菜单,甚至是多级的下拉菜单,比如这款jQuery/CSS3飘带状多级下拉菜单就非常华丽.但今天要介绍的这款j ...

  4. 8款基于Jquery的WEB前端动画特效

    1.超炫酷的30个jQuery按钮悬停动画 按钮插件是最常见的jQuery插件之一,因为它用途广泛,而且配置起来最为方便.今天我们要分享的是30个超炫酷的jQuery悬停按钮动画,当我们将鼠标滑过按钮 ...

  5. 一款基于jquery ui的动画提交表单

    今天要给大家分享一款基于jquery ui的动画提交表单.这款提交表单的的效果是以动画的形式依次列表所需填写的信息.效果非常不错,效果图如下: 在线预览   源码下载 实现的代码. html代码: & ...

  6. 分享一款基于jquery的圆形动画按钮

    之前为大家介绍过一款纯css3实现的圆形旋转分享按钮.今天要给大家带来一款基于jquery的圆形动画按钮.这款按钮鼠标经过的时候以边框转圈,然后逐渐消息,在实例中给出了四种颜色的demo.效果图如下: ...

  7. 30款基于 jQuery & CSS3 的加载动画和进度条插件

    我们所生活每一天看到的新技术或新设计潮流的兴起,Web 开发正处在上升的时代.HTML5 & CSS3 技术的发展让 Web 端可以实现的功能越来越强大. 加载动画和进度条使网站更具吸引力.该 ...

  8. 一款基于jquery的喜欢动画按钮

    今天给大家带来一款基于jquery的喜欢动画按钮.这个实例中给了三种动画特效.效果图如下: 在线预览   源码下载 实现的代码. html代码: <p class='heading'> C ...

  9. 10款基于jquery的web前端特效及源码下载

    1.jQuery时间轴插件:jQuery Timelinr 这是一款可用于展示历史和计划的时间轴插件,尤其比较适合一些网站展示发展历程.大事件等场景.该插件基于jQuery,可以滑动切换.水平和垂直滚 ...

随机推荐

  1. 深入PHP内核之数组

    定义: PHP 中的数组实际上是一个有序映射.映射是一种把 values 关联到 keys 的类型.此类型在很多方面做了优化,因此可以把它当成真正的数组,或列表(向量),散列表(是映射的一种实现),字 ...

  2. windows批处理文件打印幻方

    无论是批处理文件还是shell都是没有意义的,它们只是一种工具,并且是非常低级难懂的工具. 如果不会,那就保持不会就好了.不要花费太多时间在这些没意义的事情上. 批处理的没意义体现在: 难以表达 随便 ...

  3. 深入理解Java:自定义java注解

    要深入学习注解,我们就必须能定义自己的注解,并使用注解,在定义自己的注解之前,我们就必须要了解Java为我们提供的元注解和相关定义注解的语法. 元注解: 元注解的作用就是负责注解其他注解.Java5. ...

  4. memset(&a, 0, sizeof(struct customer))函数

    memset(&a, 0, sizeof(struct customer))函数定义在memory.h中,用于给指定的内存区域赋值,在该语句中,&a指定待赋值的内存首地址,0是要赋的值 ...

  5. iOS “[App] if we're in the real pre-commit handler we can't actually add any new fences due

    最近运行APP,发现了这个问题,本着宁可错看,不可放过的原则,上stackoverFlow学习了一下: 链接:http://stackoverflow.com/questions/38458170/i ...

  6. 史上最简单的ButterKnife配置教程

    网上的教程感觉都是抄来抄去,没一个靠谱的 还是自己丰衣足食搞一个ButterKnife配置教程吧.. 我的Android Studio版本是3.3. 1.dependencies中添加依赖 imple ...

  7. OGG_GoldenGate数据迁移三进程Extract / Dump / Relicat(案例)

    2014-03-04 Created By BaoXinjian

  8. Xfire实现webservice各种报错详解

    一.No write method for property {http://vo.aa.com}new in class com.aa.vo.TA 使用xfire的ws调用时,会将对象与xml进行捆 ...

  9. python标准库介绍——10 sys 模块详解

    ==sys 模块== ``sys`` 模块提供了许多函数和变量来处理 Python 运行时环境的不同部分. === 处理命令行参数=== 在解释器启动后, ``argv`` 列表包含了传递给脚本的所有 ...

  10. django 数据库获取值

    数据库表中的内容如下: models.Step_Type.objects.values()获取model中的符合条件的值, 实际为把表中的所有值都查询出来,如查询结果为:<QuerySet [{ ...