黑松山资源网 Design By www.paidiu.com
前言
给大家分享一下前端用处很多的带小图标的搜索框的制作方法。
效果展示
基本思路
1、搜索图像用绝对定位放到搜索框的上方
2、input框设置文本缩进,大小为搜索图像大小加上图像左右两边的外边距
准备
只需一个搜索图标图片,类似于下图
代码
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>搜索框demo</title> <style type="text/css"> *{ margin: 0; padding: 0; } body{ width: 100vw; height: 100vh; background: radial-gradient(at center, #3498db,#2980b9); display: flex; justify-content: center; align-items: center; } div.search{ height: 40px; width: 500px; } div.search form{ width: 100%; height: 100%; } div.search form input:nth-child(2){ width: 400px; height: 100%; font-size: 16px; text-indent: 40px; border: none; float: left; } div.search form input:nth-child(3){ width: 100px; height: 100%; font-size: 16px; letter-spacing: 5px; border: none; } div.search form img{ position: absolute; left: 50vw; transform: translateX(-250px); margin-top: 10px; margin-left: 10px; height: 20px; } </style> </head> <body> <div class="search"> <form action="#" method="post"> <img src="./search_ico.png" alt=""> <input type="text" name="condition" placeholder="请输入搜索条件"> <input type="submit" value="搜索"> </form> </div> </body> </html>
总结
以上所述是小编给大家介绍的基于html css实现带搜索图标的搜索框功能,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!
如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!
黑松山资源网 Design By www.paidiu.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
黑松山资源网 Design By www.paidiu.com
暂无评论...
更新日志
2024年09月20日
2024年09月20日
- 战锤40K星际战士2狙击职业介绍|狙击职业技能效果一览
- RobertSaxtonTheResurrectionoftheSoldiers(2024)[24Bit-192kHz]FLAC
- 唐成杨东哥弹唱《情若真HQ》头版限量编号[WAV+CUE]
- 柏菲·HIFI风情1《一杯香茶》限量开盘母带ORMCD[WAV+CUE]
- 发糖了!《黑神话》动画导演绘制八戒紫蛛儿中秋贺图
- “时光系列”新作《时光3:永耀之境》首曝:画风更真实的恋爱模拟RPG
- 《战地》游戏主管:始终认为《战地》未来销量能超越《使命召唤》
- 《伤感民谣 值得收藏的音乐极品 2CD》[WAV/分轨][1.2GB]
- 《邓紫棋 巨肺唱将小天后有心人 2CD》[WAV/分轨][1.2GB]
- 《迪克牛仔 坛奇精选 2CD台首版》 [WAV+CUE][600MB]
- 陈明.1998-为了爱影视歌曲+新歌【中唱】【WAV+CUE】
- 黄小琥.2009-简单/不简单【华纳】【WAV+CUE】
- 洪卓立.2010-TASTE.OF.LOVE新曲+精丫英皇娱乐】【WAV+CUE】
- 战锤40K星际战士2职业强度排行
- 交错战线PVE国家队成员以及常用角色推荐