濮阳杆衣贸易有限公司

主頁 > 知識庫 > HTML中的表單Form實(shí)現(xiàn)居中效果

HTML中的表單Form實(shí)現(xiàn)居中效果

熱門標(biāo)簽:crm外呼系統(tǒng)好不好 重慶人工智能電銷機(jī)器人報(bào)價(jià) 電話機(jī)器人批發(fā) 強(qiáng)訊外呼系統(tǒng) 貴陽ai外呼系統(tǒng) 智能電銷機(jī)器人廣告語 愛巢地圖標(biāo)注 電銷外呼線路改不外呼線路 長春極信防封電銷卡公司

之前碰到一個作業(yè),給了一張圖片,讓按照圖片樣式做一個表單,但在所有功能都實(shí)現(xiàn)后,發(fā)現(xiàn)無法讓表單居中,一直縮在左上角,看起來很難看。在經(jīng)過了各種修改后,終于成功將表單居中,下面分享一下我所經(jīng)歷過程中的錯誤與最終結(jié)果。(因?yàn)樽鲞@部分作業(yè)的時候還沒有學(xué) css,所以沒用)

1、剛做出來的樣子

<form>
			<label for="firstname">名字:</label>
			<input type="text" name="firstname" id="firstname" required="required" value="" /><br />
		
			<label for="lastname">姓氏:</label>
			<input type="text" name="lastname" id="lastname" required="required" value="" /><br />
		
			<label for="login name">登錄名:</label>
			<input type="text" name="login name" required="required" pattern="^\w{4,8}$" id="login name" value="" />(可包含a-z、0-9和下劃線)<br />
		
			<label for="password">密碼:</label>
			<input type="password" name="password" required="required" pattern="^[a-zA-Z]\w{5,17}$" id="password" value="" />(至少包含6個字符)<br />
		
			<label for="password2">再次輸入密碼:</label>
			<input type="password" name="password2" required="required" pattern="^[a-zA-Z]\w{5,17}$" id="password2" value="" /><br />
		
			<label for="myEmail">電子郵箱:</label>
			<input type="email" name="myEmail" id="myEmail" value="" />(必須包含@字符)
		</form>

看起來很別扭,所以要繼續(xù)改進(jìn)一下。。。

2、經(jīng)過修改后


 

看起來好像更別扭了,但是實(shí)現(xiàn)了居中,到這里時,我也不知道自己用的 < center> 對不對。。。

<center>
	<form>
		`````
		`````
	</ form>
</ center>

3、使用表格布局后


 

這就是在經(jīng)過了一晚上的修改后,最終呈現(xiàn)的結(jié)果。

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<link rel="icon" type="text/css" href="./img/favicon.png"/>
		<title></title>
	</head>
	<body>
		<center>
		<form action="Success.html" target="_blank" method="get">
			<table border="0" cellspacing="" cellpadding="">
				<tr>
					<td><label for="firstname">名字:</label></td>
					<td><input type="text" name="firstname" id="firstname" required="required" value="" /></td>
				</tr>
				<tr>
					<td><label for="lastname">姓氏:</label></td>
					<td><input type="text" name="lastname" id="lastname" required="required" value="" /></td>
				</tr>
				<tr>
					<td><label for="login name">登錄名:</label></td>
					<td><input type="text" name="login name" required="required" pattern="^\w{4,8}$" id="login name" value="" />(可包含a-z、0-9和下劃線)</td>
				</tr>
				<tr>
					<td><label for="password">密碼:</label></td>
					<td><input type="password" name="password" required="required" pattern="^[a-zA-Z]\w{5,17}$" id="password" value="" />(至少包含6個字符)</td>
				</tr>
				<tr>
					<td><label for="password2">再次輸入密碼:</label></td>
					<td><input type="password" name="password2" required="required" pattern="^[a-zA-Z]\w{5,17}$" id="password2" value="" /></td>
				</tr>
				<tr>
					<td><label for="myEmail">電子郵箱:</label></td>
					<td><input type="email" name="myEmail" id="myEmail" value="" />(必須包含@字符)</td>
				</tr>
				<tr>
					<td><label>性別:</label></td>
					<td>
						<input type="radio" name="sex" id="" value="male" />男<img src="./img/Male.gif" >
						<input type="radio" name="sex" id="" value="female" />女<img src="./img/Female.gif" >
					</td>
				</tr>
				<tr>
					<td><label>頭像:</label></td>
					<td><input type="file" name="myFile" /></td>
				</tr>
				<tr>
					<td><label>愛好:</label></td>
					<td>
						<input type="checkbox" name="hobby" id="" value="運(yùn)動" />運(yùn)動 
						<input type="checkbox" name="hobby" id="" value="聊天" />聊天
						<input type="checkbox" name="hobby" id="" value="玩游戲" />玩游戲
					</td>
				</tr>
				<tr>
					<td><label>出生日期:</label></td>
					<td>
						<input type="text" size="1" name="year"placeholder="yyyy" id="" value="" />年
						<select name="month">
							<option value ="0">[選擇月份]</option>
							<option value ="1">1月</option>
							<option value ="2">2月</option>
							<option value ="3">3月</option>
							<option value ="4">4月</option>
							<option value ="5">5月</option>
							<option value ="6">6月</option>
							<option value ="7">7月</option>
							<option value ="8">8月</option>
							<option value ="9">9月</option>
							<option value ="10">10月</option>
							<option value ="11">11月</option>
							<option value ="12">12月</option>
						</select>
						<input type="text" size="1" name="day" placeholder="dd"/>日
					</td>
				</tr>
			</table>
			<input type="image" src="img/submit.gif" value="提交" />
			<input type="image" src="img/reset.gif" onclick="reset();return false;" value="重填" />		
		</form>
		</center>
	</body>
</html>

若覺得左邊的標(biāo)簽左對齊不好看,也可以在 < td >標(biāo)簽中加入align=“right”,使文字右對齊

<td align="right"><label for="firstname">名字:</label></td>

到此這篇關(guān)于HTML中的表單Form實(shí)現(xiàn)居中效果的文章就介紹到這了,更多相關(guān)HTML表單Form居中內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持腳本之家!

標(biāo)簽:清遠(yuǎn) 吳忠 保定 上海 陜西 山南 內(nèi)蒙古 廣安

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《HTML中的表單Form實(shí)現(xiàn)居中效果》,本文關(guān)鍵詞  HTML,中的,表單,Form,實(shí)現(xiàn),;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《HTML中的表單Form實(shí)現(xiàn)居中效果》相關(guān)的同類信息!
  • 本頁收集關(guān)于HTML中的表單Form實(shí)現(xiàn)居中效果的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    遂川县| 芷江| 屯门区| 灵璧县| 盘锦市| 承德市| 游戏| 永寿县| 汝南县| 玉环县| 神木县| 鹤峰县| 抚顺县| 马龙县| 太康县| 靖宇县| 绥宁县| 新疆| 比如县| 文昌市| 清河县| 庆元县| 惠东县| 安多县| 手机| 聂荣县| 广元市| 兴文县| 六盘水市| 清涧县| 碌曲县| 广东省| 富源县| 桦川县| 彰化市| 永城市| 彰武县| 双柏县| 东辽县| 获嘉县| 栾城县|