這裏是我的html代碼:如何在CSS中使該圖像「可點擊」?
<div class="maindiv">
<form id="myform" name="myform" method="post" action="schitems.php">
<input type="search" id="itemcd" name="itemcd" class="inputfields" placeholder="Type an Ingredient..." />
</form>
</div>
而這裏的CSS,使它看起來酷和現代:
#myform {width:260px; margin:0 auto;}
input[type="search"]{
padding:18px 15px 18px 52px;
font-size:1rem;
color:#1f5350;
/*removing boder from search box*/
border:none;
/*defining background image as a search symbol*/
background-image:url(search.png);
background-repeat:no-repeat;
/*background-size*/
-webkit-background-size:25px 26px;
-moz-background-size:25px 26px;
-o-background-size:25px 26px;
background-size:25px 26px;
/*positioning background image*/
background-position:8px 14px;
/*changing background color form white*/
background-color:#7accc8;
outline:0;
}
/*now using placeholder property to change color of placholder text and making it consitent accross the browser by use of prefix*/
input[type="search"]::-webkit-input-placeholder{
color:#b1e0de;
}
input[type="search"]:-moz-placeholder { /* Firefox 18- */
color: #b1e0de;
}
input[type="search"]::-moz-placeholder { /* Firefox 19+ */
color: #b1e0de;
}
input[type="search"]:-ms-input-placeholder { /* interner explorer*/
color: #b1e0de;
}
我遇到的問題是,搜索圖標只是一個靜態圖像。 我希望它能夠提交用戶輸入的信息,而不只是站在那裏作爲裝飾圖像。當用戶在搜索框中鍵入內容時,他點擊該圖標時,應該將他帶到顯示搜索結果的頁面。有什麼辦法可以做到這一點? 我見過很多現代網站都有這個搜索圖標,它是可點擊的......但是我的邏輯並沒有把我帶到我可以理解的程度......任何人都可以幫忙嗎?