html搜索框如何設置?html搜索框input標簽的使用方法案例
發表時間:2023-09-01 來源:明輝站整理相關軟件相關文章人氣:
[摘要]本篇文章主要講述的是關于HTML 搜索框的設置,還有html 搜索框input標簽的一些使用方法實例,接下來就讓我們一起來閱讀這篇關于html 搜索框的文章吧首先我們來設置一個簡單的搜索框:<input type="text" class="aa"&g...
本篇文章主要講述的是關于HTML 搜索框的設置,還有html 搜索框input標簽的一些使用方法實例,接下來就讓我們一起來閱讀這篇關于html 搜索框的文章吧
首先我們來設置一個簡單的搜索框:
<input type="text" class="aa"><input type="button" value="搜索" class="bb">
這是一個最簡單樣式的搜索框,沒有很復雜的樣式。如果需要設計樣式可以根據class="aa"來寫樣式,.aa{}在括號中添加代碼即可,當然這是框的樣式,按鈕的樣式.bb{}在括號中填寫代碼即可。在瀏覽器中顯示的效果如圖:

這就是一個簡單的搜索框的代碼。
現在說說input標簽的使用方法,先看個實例
我們來看點更高深的搜索框完整的代碼:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>PHP中文網</title>
<meta name="description" content="">
<meta name="keywords" content="">
<link href="" rel="stylesheet">
<style type="text/css">
#box{
width: 380px;
margin: 30px auto;
font-family: 'Microsoft YaHei';
font-size: 14px;
}
input{
width: 260px;
border: 1px solid #e2e2e2;
height: 30px;
float: left;
background-image: url(images/search.jpg);
background-repeat: no-repeat;
background-size: 25px;
background-position:5px center;
padding:0 0 0 40px;
}
#search{
width: 78px;
height: 32px;
float: right;
background: black;
color: white;
text-align: center;
line-height: 32px;
cursor: pointer;
}
</style>
</head>
<body>
<div id="box">
<input type="text" name="search" placeholder="請輸入關鍵字">
<div id="search">搜索</div>
</div>
</body>
</html>
這個代碼看效果圖:

這個效果就比第一個好看太多了,就是多了點代碼,都是基礎的css樣式的知識,如果有不懂的可以在下方留言。
注意: <input> 元素是空的,它只包含標簽屬性。
提示: 你可以使用 <label> 元素來定義 <input> 元素的標注。
好了,以上就是關于我們這篇關于html input標簽的用法,有問題的可以在下方留言。
【小編推薦】
html空格代碼怎么寫?html空格代碼的表現方式總結
html下拉菜單怎么做?html下拉菜單的代碼實例介紹
以上就是html搜索框怎么設置?html搜索框input標簽的使用方法實例的詳細內容,更多請關注php中文網其它相關文章!
網站建設是一個廣義的術語,涵蓋了許多不同的技能和學科中所使用的生產和維護的網站。