前端自定義搜索框實現


定義一個前端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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM