<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8">
<!-- base 是頁面的基準路徑,如果頁面中的路徑有 明確指向 某個目錄那它的路徑會直接生效,如果是在本及路徑下面的相對路徑就可以省去這個基準路徑 -->
<style type="text/css">
</style>
</head>
<body>
<!-- form是表單元素,用來獲取用戶錄入的信息,並且具體提交到目標頁面的功能 -->
<form action="res/neighbor.html">
<fieldset>
<legend>基本信息</legend>
<br>
<!-- 文本框 -->
<label>用戶:</label><input type="text"><br><br>
<!-- 密碼框 -->
<label>密碼:</label><input type="password"><br><br>
</fieldset>
<fieldset>
<legend>高級信息</legend>
<br>
<!-- 單選框 -->
<label>性別:</label>
<input type="radio" name="sex" id="male"><label for="male">男</label>
<input type="radio" name="sex" id="female"><label for="female">女</label><br><br>
<!-- 複選框 -->
<label>愛好:</label>
<input type="checkbox" name="interest">LOL
<input type="checkbox" name="interest">DOTA
<input type="checkbox" name="interest">CF
<input type="checkbox" name="interest">DNF
<input type="checkbox" name="interest">CODING
<input type="checkbox" name="interest">2333<br><br>
<!-- 下拉列表 -->
<label>學校:</label>
<select>
<option>洛陽理工</option>
<option>鄭州信息工程學院</option>
<option>河南建築職業學院</option>
<option>鄭州理工</option>
</select><br><br>
</fieldset>
<!-- 按鈕 --><br>
<input type="button" value="普通按鈕">
<input type="submit" value="登錄">
<input type="reset" value="重置">
</form>
</body>
</html>
知識點:
1.fieldset屬性表示外圍框,fieldset可以將表單內的相關元素分組,legend 爲 fieldset 定義標題。
2.label標籤爲input定義標註(標記)。
3.input,以收集用戶的信息爲主,根據不同的type類型,分爲單選框、複選框、按鈕等等。
① radio,單選框,代碼29、30行,兩行對比,name表示,把選項綁定到性別裏面,並且只能選一個,id和for有點定位的概念,點擊後面的內容即可
選中前面的單選框。
② checkbox,複選框,代碼33到38行,name同上。
③ button,普通按鈕,代碼50行,value爲顯示的文字。
④ submit,提交按鈕,代碼51行,value爲顯示的文字。
⑤ reset, 重置按鈕,代碼52行,value爲顯示的文字。
4.select,創建單選或多選菜單,option可設置選項。