分享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 相关文章推荐
10 套华丽的CSS3 按钮小结
Oct 03 HTML / CSS
CSS3中的@keyframes关键帧动画的选择器绑定
Jun 13 HTML / CSS
纯CSS3制作的鼠标悬停时边框旋转
Jan 03 HTML / CSS
仿酷狗html5手机音乐播放器主要部分代码
May 15 HTML / CSS
html5的画布canvas——画出弧线、旋转的图形实例代码+效果图
Jun 09 HTML / CSS
html5实现canvas阴影效果示例
May 07 HTML / CSS
浅谈html5增强的页面元素
Jun 14 HTML / CSS
通过HTML5规范搞定i、em、b、strong元素的区别
Mar 04 HTML / CSS
HTML5页面直接调用百度地图API获取当前位置直接导航目的地的实现代码
Mar 02 HTML / CSS
浅析HTML5中的download属性使用
Mar 13 HTML / CSS
HTML中meta标签及Keywords
Apr 15 HTML / CSS
详解CSS3.0(Cascading Style Sheet) 层叠级联样式表
Jul 16 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 和 COM
2006/10/09 PHP
PHP程序级守护进程的实现与优化的使用概述
2013/05/02 PHP
php计算两个日期时间差(返回年、月、日)
2014/06/19 PHP
PHP里8个鲜为人知的安全函数分析
2014/12/09 PHP
解决laravel 5.1报错:No supported encrypter found的办法
2017/06/07 PHP
jquery中ajax学习笔记4
2011/10/16 Javascript
第一次接触神奇的Bootstrap
2016/10/14 Javascript
详解jQuery的表单验证插件--Validation
2016/12/21 Javascript
JS简单实现移动端日历功能示例
2016/12/28 Javascript
js获取地址栏中传递的参数(两种方法)
2017/02/08 Javascript
解析Vue2.0双向绑定实现原理
2017/02/23 Javascript
Bootstrap 树控件使用经验分享(图文解说)
2017/11/06 Javascript
JS运动改变单物体透明度的方法分析
2018/01/23 Javascript
微信小程序显示倒计时功能示例【测试可用】
2018/12/03 Javascript
Layui之table中的radio在切换分页时无法记住选中状态的解决方法
2019/09/02 Javascript
Vue elementui字体图标显示问题解决方案
2020/08/18 Javascript
jQuery实现简单三级联动效果
2020/09/05 jQuery
原生JavaScript实现拖动校验功能
2020/09/29 Javascript
详解Python中内置的NotImplemented类型的用法
2015/03/31 Python
Python的Flask框架中使用Flask-SQLAlchemy管理数据库的教程
2016/06/14 Python
Python实现并行抓取整站40万条房价数据(可更换抓取城市)
2016/12/14 Python
python 爬虫一键爬取 淘宝天猫宝贝页面主图颜色图和详情图的教程
2018/05/22 Python
Python告诉你木马程序的键盘记录原理
2019/02/02 Python
PyQt5重写QComboBox的鼠标点击事件方法
2019/06/25 Python
pytorch 指定gpu训练与多gpu并行训练示例
2019/12/31 Python
Python3.7 读取音频根据文件名生成脚本的代码
2020/04/07 Python
关于HTML5的22个初级技巧(图文教程)
2012/06/21 HTML / CSS
美国婚礼装饰和活动用品批发供应商:Event Decor Direct
2018/10/12 全球购物
ZINVO手表官网:男士和女士手表
2019/03/10 全球购物
会计专业应届生自荐信
2014/02/07 职场文书
大学生学期自我鉴定
2014/03/19 职场文书
民间借贷借条范本
2015/05/25 职场文书
Python基础之数据类型知识汇总
2021/05/18 Python
Python 批量下载阴阳师网站壁纸
2021/05/19 Python
只用20行Python代码实现屏幕录制功能
2021/06/02 Python
MySQL系列之十一 日志记录
2021/07/02 MySQL