分享8款纯CSS3实现的搜索框功能


Posted in HTML / CSS onSeptember 14, 2017

效果图:

分享8款纯CSS3实现的搜索框功能

<!DOCTYPE html>  
<html lang="en">  
<head>  
    <meta charset="UTF-8">  
    <meta name="viewport" content="width=device-width, initial-scale=1.0">  
    <title>8款纯CSS3搜索框</title>  
    <link href="http://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">  
    <link rel="stylesheet" href="style.css">  
    <style>  
        * {  
            box-sizing: border-box;  
        }  
        body {  
            margin: 0;  
            padding: 0;  
            background: #494A5F;  
            font-weight: 500;  
            font-family: "Microsoft YaHei","宋体","Segoe UI", "Lucida Grande", Helvetica, Arial,sans-serif, FreeSans, Arimo;  
        }  
        #container {  
            width: 500px;  
            height: 820px;  
            margin: 0 auto;  
        }  
        div.search {padding: 30px 0;}  
        form {  
            position: relative;  
            width: 300px;  
            margin: 0 auto;  
        }  
        input, button {  
            border: none;  
            outline: none;  
        }  
        input {  
            width: 100%;  
            height: 42px;  
            padding-left: 13px;  
            padding-right:46px;  
        }  
        button {  
            height: 42px;  
            width: 42px;  
            cursor: pointer;  
            position: absolute;  
        }  
        /*搜索框1*/  
        .bar1 {background: #A3D0C3;}  
        .bar1 input {  
            border: 2px solid #7BA7AB;  
            border-radius: 5px;  
            background: #F9F0DA;  
            color: #9E9C9C;  
        }  
        .bar1 button {  
            top: 0;  
            right: 0;  
            background: #7BA7AB;  
            border-radius: 0 5px 5px 0;  
        }  
        .bar1 button:before {  
            content: "\f002";  
            font-family: FontAwesome;  
            font-size: 16px;  
            color: #F9F0DA;  
        }  
        /*搜索框2*/  
        .bar2 {background: #DABB52;}  
        .bar2 input, .bar2 button {  
            border-radius: 3px;  
        }  
        .bar2 input {  
            background: #F9F0DA;  
        }  
        .bar2 button {  
            height: 26px;  
            width: 26px;  
            top: 8px;  
            right: 8px;  
            background: #F15B42;  
        }  
        .bar2 button:before {  
            content: "\f105";  
            font-family: FontAwesome;  
            color: #F9F0DA;  
            font-size: 20px;  
            font-weight: bold;  
        }  
        /*搜索框3*/  
        .bar3 {background: #F9F0DA;}  
        .bar3 form {background: #A3D0C3;}  
        .bar3 input, .bar3 button {  
            background: transparent;  
        }  
        .bar3 button {  
            top: 0;  
            right: 0;  
        }  
        .bar3 button:before {  
            content: "\f002";  
            font-family: FontAwesome;  
            font-size: 16px;  
            color: #F9F0DA;  
        }  
        /*搜索框4*/  
        .bar4 {background: #F15B42;}  
        .bar4 form {  
            background: #F9F0DA;  
            border-bottom: 2px solid #BE290E;  
        }  
        .bar4 input, .bar4 button {  
            background: transparent;  
        }  
        .bar4 button {  
            top: 0;  
            right: 0;  
        }  
        .bar4 button:before {  
            content: "\f178";  
            font-family: FontAwesome;  
            font-size: 20px;  
            color: #be290e;  
        }  
        /*搜索框5*/  
        .bar5 {background: #683B4D;}  
        .bar5 input, .bar5 button {  
            background: transparent;  
        }  
        .bar5 input {  
            border: 2px solid #F9F0DA;  
        }  
        .bar5 button {  
            top: 0;  
            right: 0;  
        }  
        .bar5 button:before {  
            content: "\f002";  
            font-family: FontAwesome;  
            font-size: 16px;  
            color: #F9F0DA;  
        }  
        .bar5 input:focus {  
            border-color: #311c24  
        }  
        /*搜索框6*/  
        .bar6 {background: #F9F0DA;}  
        .bar6 input {  
            border: 2px solid #c5464a;  
            border-radius: 5px;  
            background: transparent;  
            top: 0;  
            right: 0;  
        }  
        .bar6 button {  
            background: #c5464a;  
            border-radius: 0 5px 5px 0;  
            width: 60px;  
            top: 0;  
            right: 0;  
        }  
        .bar6 button:before {  
            content: "搜索";  
            font-size: 13px;  
            color: #F9F0DA;  
        }  
        /*搜索框7*/  
        .bar7 {background: #7BA7AB;}  
        .bar7 form {  
            height: 42px;  
        }  
        .bar7 input {  
            width: 250px;  
            border-radius: 42px;  
            border: 2px solid #324B4E;  
            background: #F9F0DA;  
            transition: .3s linear;  
            float: right;  
        }  
        .bar7 input:focus {  
            width: 300px;  
        }  
        .bar7 button {  
            background: none;  
            top: -2px;  
            right: 0;  
        }  
        .bar7 button:before{  
            content: "\f002";  
            font-family: FontAwesome;  
            color: #324b4e;  
        }  
        /*搜索框8*/  
        .bar8 {background: #B46381;}  
        .bar8 form {  
            height: 42px;  
        }  
        .bar8 input {  
            width: 0;  
            padding: 0 42px 0 15px;  
            border-bottom: 2px solid transparent;  
            background: transparent;  
            transition: .3s linear;  
            position: absolute;  
            top: 0;  
            right: 0;  
            z-index: 2;  
        }  
        .bar8 input:focus {  
            width: 300px;  
            z-index: 1;  
            border-bottom: 2px solid #F9F0DA;  
        }  
        .bar8 button {  
            background: #683B4D;  
            top: 0;  
            right: 0;  
        }  
        .bar8 button:before {  
            content: "\f002";  
            font-family: FontAwesome;  
            font-size: 16px;  
            color: #F9F0DA;  
        }  
    </style>  
</head>  
<body>  
<div id="container">  
    <div class="search bar1">  
        <form>  
            <input type="text" placeholder="请输入您要搜索的内容...">  
            <button type="submit"></button>  
        </form>  
    </div>  
    <div class="search bar2">  
        <form>  
            <input type="text" placeholder="请输入您要搜索的内容...">  
            <button type="submit"></button>  
        </form>  
    </div>  
    <div class="search bar3">  
        <form>  
            <input type="text" placeholder="请输入您要搜索的内容...">  
            <button type="submit"></button>  
        </form>  
    </div>  
    <div class="search bar4">  
        <form>  
            <input type="text" placeholder="请输入您要搜索的内容...">  
            <button type="submit"></button>  
        </form>  
    </div>  
    <div class="search bar5">  
        <form>  
            <input type="text" placeholder="请输入您要搜索的内容...">  
            <button type="submit"></button>  
        </form>  
    </div>  
    <div class="search bar6">  
        <form>  
            <input type="text" placeholder="请输入您要搜索的内容...">  
            <button type="submit"></button>  
        </form>  
    </div>  
    <div class="search bar7">  
        <form>  
            <input type="text" placeholder="请输入您要搜索的内容...">  
            <button type="submit"></button>  
        </form>  
    </div>  
    <div class="search bar8">  
        <form>  
            <input type="text" placeholder="请输入您要搜索的内容...">  
            <button type="submit"></button>  
        </form>  
    </div>  
</div>  
</body>  
</html>

总结

以上所述是小编给大家介绍的 分享8款纯CSS3实现的搜索框功能,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对三水点靠木网站的支持!

HTML / CSS 相关文章推荐
各大浏览器 CSS3 和 HTML5 兼容速查表 图文
Apr 01 HTML / CSS
CSS3 Pie工具推荐--让IE6-8支持一些优秀的CSS3特性
Sep 02 HTML / CSS
纯css3实现图片翻牌特效
Mar 10 HTML / CSS
基于HTML5 Canvas:字符串,路径,背景,图片的详解
May 09 HTML / CSS
使用HTML5的Canvas绘制曲线的简单方法
Sep 08 HTML / CSS
Html5新标签datalist实现输入框与后台数据库数据的动态匹配
May 18 HTML / CSS
使用Html5中的cavas画一面国旗
Sep 25 HTML / CSS
html5移动端自适应布局的实现
Apr 15 HTML / CSS
基于html5 canvas做批改作业的小插件
May 20 HTML / CSS
HTML5 层的叠加的实现
Jul 07 HTML / CSS
AmazeUI 图标的示例代码
Aug 13 HTML / CSS
html+css 实现简易导航栏功能
Apr 07 HTML / CSS
详解CSS3 用border写 空心三角箭头 (两种写法)
Sep 29 #HTML / CSS
详解使用CSS3的@media来编写响应式的页面
Nov 01 #HTML / CSS
CSS3轻松实现圆角效果
Nov 09 #HTML / CSS
详解css3自定义滚动条样式写法
Dec 25 #HTML / CSS
简单掌握CSS3将文字描边及填充文字颜色的方法
Mar 07 #HTML / CSS
CSS3中文字镂空、透明值、阴影效果设置示例小结
Mar 07 #HTML / CSS
利用CSS的Sass预处理器(框架)来制作居中效果
Mar 10 #HTML / CSS
You might like
PHP基础教程(php入门基础教程)一些code代码
2013/01/06 PHP
用PHP和Shell写Hadoop的MapReduce程序
2014/04/15 PHP
php常用hash加密函数
2014/11/22 PHP
php计算到指定日期还有多少天的方法
2015/04/14 PHP
Yii2配置Nginx伪静态的方法
2017/05/05 PHP
解决jQuery插件tipswindown与hintbox冲突
2010/11/05 Javascript
利用jquery动画特效和css打造的侧边弹出垂直导航
2014/04/04 Javascript
jquery实现当滑动到一定位置时固定效果
2014/06/17 Javascript
require.js深入了解 require.js特性介绍
2014/09/04 Javascript
js实现动态加载脚本的方法实例汇总
2015/11/02 Javascript
js格式化时间的方法
2015/12/18 Javascript
微信小程序 详解页面跳转与返回并回传数据
2017/02/13 Javascript
mui 打开新窗口的方式总结及注意事项
2017/08/20 Javascript
使用vue-infinite-scroll实现无限滚动效果
2018/06/22 Javascript
原生JS实现$.param() 函数的方法
2018/08/10 Javascript
关于微信小程序bug记录与解决方法
2018/08/15 Javascript
基于axios 解决跨域cookie丢失的问题
2018/09/26 Javascript
React 源码中的依赖注入方法
2018/11/07 Javascript
[00:43]FTP典藏礼包 DOTA2三大英雄霸气新套装
2014/03/21 DOTA
[56:46]Liquid vs IG 2018国际邀请赛小组赛BO2 第二场 8.17
2018/08/18 DOTA
简单的连接MySQL与Python的Bottle框架的方法
2015/04/30 Python
实例解析Python的Twisted框架中Deferred对象的用法
2016/05/25 Python
Python Collatz序列实现过程解析
2019/10/12 Python
python3实现绘制二维点图
2019/12/04 Python
15个应该掌握的Jupyter Notebook使用技巧(小结)
2020/09/23 Python
canvas探照灯效果的示例代码
2018/11/30 HTML / CSS
行政专员工作职责
2013/12/22 职场文书
大学生志愿者感言
2014/01/15 职场文书
美术专业个人自我评价
2014/01/18 职场文书
新闻编辑自荐书范文
2014/02/12 职场文书
舞蹈教育学专业自荐信
2014/06/15 职场文书
电信营业员岗位职责
2015/04/14 职场文书
搞笑欢迎词大全
2015/09/30 职场文书
大学生村官工作心得体会
2016/01/23 职场文书
如何用JavaScipt测网速
2021/05/09 Javascript
在虚拟机中安装windows server 2008的图文教程
2022/06/28 Servers