分享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 3D制作实战案例分析
Sep 18 HTML / CSS
一款利用html5和css3实现的3D滚动特效的教程
Jan 04 HTML / CSS
5分钟让你掌握css3阴影、倒影、渐变小技巧(小编推荐)
Aug 15 HTML / CSS
css3 实现圆形旋转倒计时
Feb 24 HTML / CSS
HTML5打开本地app应用的方法
Mar 31 HTML / CSS
突袭HTML5之Javascript API扩展4—拖拽(Drag/Drop)概述
Jan 31 HTML / CSS
HTML5 canvas基本绘图之图形变换
Jun 27 HTML / CSS
浅谈HTML5 服务器推送事件(Server-sent Events)
Aug 01 HTML / CSS
基于HTML5 WebGL的3D机房的示例
Mar 16 HTML / CSS
Html5之自定义属性(data-,dataset)
Nov 19 HTML / CSS
HTML5调用手机发短信和打电话功能
Apr 29 HTML / CSS
html原生table实现合并单元格以及合并表头的示例代码
May 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
Yii数据读取与跳转参数传递用法实例分析
2016/07/12 PHP
javascript new一个对象的实质
2010/01/07 Javascript
javascript面向对象入门基础详细介绍
2012/09/05 Javascript
js动态给table添加/删除tr的方法
2013/08/02 Javascript
js日期相关函数总结分享
2013/10/15 Javascript
jQuery浏览器CSS3特写兼容实例
2015/01/19 Javascript
javascript产生随机数方法汇总
2016/01/25 Javascript
全面了解函数声明与函数表达式、变量提升
2016/08/09 Javascript
基于JavaScript实现前端文件的断点续传
2016/10/17 Javascript
AngularJS深入探讨scope,继承结构,事件系统和生命周期
2016/11/02 Javascript
js+div+css下拉导航菜单完整代码分享
2016/12/28 Javascript
angular.js + require.js构建模块化单页面应用的方法步骤
2017/07/19 Javascript
JavaScript中的E-mail 地址格式验证
2018/03/28 Javascript
webstorm中配置nodejs环境及npm的实例
2018/05/15 NodeJs
详解vue通过NGINX部署在子目录或者二级目录实践
2018/09/03 Javascript
用vue写一个日历
2020/11/02 Javascript
轻松实现python搭建微信公众平台
2016/02/16 Python
python 数据的清理行为实例详解
2017/07/12 Python
python的paramiko模块实现远程控制和传输示例
2017/10/13 Python
python实现机械分词之逆向最大匹配算法代码示例
2017/12/13 Python
Python制作豆瓣图片的爬虫
2017/12/28 Python
Pyqt实现无边框窗口拖动以及窗口大小改变
2018/04/19 Python
Django 如何使用日期时间选择器规范用户的时间输入示例代码详解
2020/05/22 Python
pytorch快速搭建神经网络_Sequential操作
2020/06/17 Python
Python 测试框架unittest和pytest的优劣
2020/09/26 Python
python实现图片,视频人脸识别(opencv版)
2020/11/18 Python
节省高达65%的城市景点费用:Go City
2019/07/06 全球购物
美国知名眼镜网站:Target Optical
2020/04/04 全球购物
迪士尼法国在线商店:shopDisney FR
2020/12/03 全球购物
历史学专业毕业生求职信
2013/09/27 职场文书
金融学专科生自我鉴定
2014/02/21 职场文书
关于保护环境的建议书
2014/05/13 职场文书
公安民警正风肃纪剖析材料
2014/10/10 职场文书
大学生个人学年总结
2015/02/15 职场文书
高校自主招生自荐信2015
2015/03/04 职场文书
Mybatis是这样防止sql注入的
2021/12/06 Java/Android