看到一款很漂亮的搜索框,于是就实现了下,现在展现给大家,希望大家喜欢。
首先,看看效果。
失去焦点时
获得焦点时
鼠标经过go按钮时
上面展示的是实现后的效果,实现的主要在css控制,再次,添加了text的获得焦点和失去焦点的事件,下面是详细代码:
1、css样式
<style type="text/css"> html, body, div{ font-size: 12px; font-family: "Meiryo","微软雅黑"; } .box{ margin: 20px; position: relative; } .search-icon{ background: url(search.png) no-repeat; width:25px; height: 25px; display:block; float: left; position: absolute; left: 2px; top: 5px; } .before{ font-size:0.875em; padding:.3em 2em .3em; border:2px solid rgb(241,202,126); width: 120px; height: 33px; } .after{ font-size:0.875em; padding:.3em 2em .3em; border:1px solid rgb(241,202,126); /*border:1px solid #4997d2;*/ width: 240px; height: 33px; } .btn{ border: none; position:absolute; left: 200px; top:2px; height: 29px; width: 38px; display:inline-block; padding:.3em .5em .3em; font-family:"Avenir LT W01 65 Medium", Arial, Helvetica, sans-serif; color:#4997d2; background: #fff; } .btn:hover{ cursor:pointer; background-color:#4997d2; color:white } </style>
2、js代码
<script src="../jquery-1.8.3.js"></script> <script> function showBefore(){ $("input#name").removeClass("after").addClass("before").val(""); $("button#search").hide(); } function showAfter(){ $("input#name").removeClass("before").addClass("after"); $("button#search").show(); } </script>
3、html代码
<div class="box"> <span class="search-icon"></span> <input class="before" id="name" type="search" name="q" placeholder="Search" autocomplete="off" onfocus="showAfter()" onblur="showBefore()"> <button type="submit" class="btn" id="search" style="display: none;">GO</button> </div>
如有疑问可联系:
QQ:1004740957
Email:niujp08@qq.com

HTML的未来将朝着更加语义化、功能化和模块化的方向发展。1)语义化将使标签更明确地描述内容,提升SEO和无障碍访问。2)功能化将引入新元素和属性,满足用户需求。3)模块化将支持组件化开发,提高代码复用性。

htmlattributesarecrucialinwebdevelopment forcontrollingBehavior,外观和功能

alt属性是HTML中标签的重要部分,用于提供图片的替代文本。1.当图片无法加载时,alt属性中的文本会显示,提升用户体验。2.屏幕阅读器使用alt属性帮助视障用户理解图片内容。3.搜索引擎索引alt属性中的文本,提高网页的SEO排名。

HTML、CSS和JavaScript在网页开发中的作用分别是:1.HTML用于构建网页结构;2.CSS用于美化网页外观;3.JavaScript用于实现动态交互。通过标签、样式和脚本,这三者共同构筑了现代网页的核心功能。

设置标签的lang属性是优化网页可访问性和SEO的关键步骤。1)在标签中设置lang属性,如。2)在多语言内容中,为不同语言部分设置lang属性,如。3)使用符合ISO639-1标准的语言代码,如"en"、"fr"、"zh"等。正确设置lang属性可以提高网页的可访问性和搜索引擎排名。

htmlattributeseresene forenhancingwebelements'functionalityandAppearance.TheyAdDinformationTodeFineBehavior,外观和互动,使网站互动,响应式,visalalyAppealing.AttributesLikutesLikeSlikEslikesrc,href,href,href,类,类型,类型,和dissabledtransfransformformformformformformformformformformformformformformforment

toCreateAlistinHtml,useforforunordedlistsandfororderedlists:1)forunorderedlists,wrapitemsinanduseforeachItem,RenderingeringAsabulleTedList.2)fororderedlists,useandfornumberedlists,useandfornumberedlists,casundfornumberedlists,customeizableWithTheTtheTthetTheTeTeptTributeFordTributeForderForderForderFerentNumberingSnumberingStyls。

HTML用于构建结构清晰的网站。1)使用标签如、、定义网站结构。2)示例展示了博客和电商网站的结构。3)避免常见错误如标签嵌套不正确。4)优化性能通过减少HTTP请求和使用语义化标签。


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

Atom编辑器mac版下载
最流行的的开源编辑器

WebStorm Mac版
好用的JavaScript开发工具

MinGW - 适用于 Windows 的极简 GNU
这个项目正在迁移到osdn.net/projects/mingw的过程中,你可以继续在那里关注我们。MinGW:GNU编译器集合(GCC)的本地Windows移植版本,可自由分发的导入库和用于构建本地Windows应用程序的头文件;包括对MSVC运行时的扩展,以支持C99功能。MinGW的所有软件都可以在64位Windows平台上运行。

适用于 Eclipse 的 SAP NetWeaver 服务器适配器
将Eclipse与SAP NetWeaver应用服务器集成。

VSCode Windows 64位 下载
微软推出的免费、功能强大的一款IDE编辑器