首页 > 其他 > 详细

前端自定义搜索框实现

时间:2019-02-23 22:12:59      阅读:198      评论:0      收藏:0      [点我收藏+]

定义一个前端div

<div class="site-search">
       <div id="search">
           <input type="text" name="s" class="text" placeholder="输入关键字搜索" />
           <button type="button" onclick="javascript:doSearch();" class="submit">搜索</button>
       </div>
   </div>

关键代码,样式调整

.site-search{
    width:25%;
    float:right;
    width:250px;
    height:50px;
}
#search{
    position:relative;
    margin-top:15px;
}
#search input{
    padding-right:30px;
}
#search button{
    position:absolute;
    right:4px;
    top:2px;
    border:none;
    padding:0;
    width:24px;
    height:24px;
    background:url("static/images/search.png") no-repeat scroll right center transparent;
    direction:ltr;
    text-indent:-9999em;
}

实现效果
技术分享图片

项目全部代码在自己的开源项目:https://github.com/u014427391/myblog

前端自定义搜索框实现

原文:https://www.cnblogs.com/mzq123/p/10424451.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!