2011-10-31 66 views
3

所以我想輸入文本框以及它們的描述,並且我希望每個文本框的長度都是相等的。例如像,我想有一個文本框,將是這樣的:輸入文本框和標籤 - 如何讓它們平等?

Username: [    ] 

但是,可以說,我也有一個輸入文本框上面寫着:「OS:」

我想它是這樣的:

Username: [    ] 
OS:  [    ] 

而且我想這是爲表內每一個輸入字段真(?或者沒有在表中,我不知道)

我將如何做到這一點?

編輯:

我有多個領域,所有這些我想是一樣的長度,即:

Username:  [    ]  Machine Name: [    ] 
OS:   [    ]  Model:  [    ] 

這裏是我的代碼:

<form action="addrecord.psp" method="get"> 
<table> 
<tr><td>Username: <input type="text" name="uname" size="12"/></td> 
<td>Machine Name:<input type="text" name="mname" size="8" /></td> 
<td>Make: <input type=text" name="make" size="8" /></td> 
<td>Model: <input type="text" name="model" size="8"/></td> 
<td>Service Tag: <input type="text" name="service" size="8"/></td></tr> 
<tr><td>Processor: <input type="text" name="processor" size="12"/></td> 
<td>Processor Speed: <input type="text" name="speed" size="4"/></td> 
<td>Amount of RAM: <input type="text" name="ram" size="3"/></td> 
<td>Type of RAM: <input type="text" name="ram2" size="4"/></td> 
<td>RAM Speed: <input type="text" name="rspeed" size="4"/></td></tr> 
<td>Graphics Card: <input type="text" name=graphics" size="8"/></td> 
<td>Wired Mac Add: <input type="text" name="wired" size="17"/></td> 
<td>Wireless Mac Add: <input type="text" name="wireless" size="17"/></td></tr> 
<tr><td>OS: <input type="text" name="os" size="12"/></td> 
<td>Deploy Date: <input type="text" name="deploy" size="12"/></td> 
<td>Last Check-up: <input type="text" name="checkup" size="12"/></td> 
<td><input type="submit" value="Submit" /></td></tr> 
</table> 
</form> 

我不噸相信我的新形式,現場提交正確,我得到以下回調:

Tra ceback(最新最後調用):

文件 「/usr/lib/python2.7/dist-packages/mod_python/importer.py」,線1537,在HandlerDispatch 默認= default_handler,ARG = REQ,沉默= hlist.silent)

文件 「/usr/lib/python2.7/dist-packages/mod_python/importer.py」,線1229,在_process_target 結果= _execute_target(配置,REQ,對象,ARG)

文件 「/usr/lib/python2.7/dist-packages/mod_python/importer.py」,線1128,在_execute_target 結果=對象(ARG)

文件 「/usr/lib/python2.7/dist-packages/mod_python/psp.py」,管線337,在處理程序 p.run()

文件「/usr/lib/python2.7/的dist-包/ mod_python的/ psp.py /var/www/inventory/addrecord.psp 「第34行,在 VALUES(%S,%」,線路243,在運行中 GLOBAL_SCOPE

文件EXEC代碼」 s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s, ,mname,make,model,service,processor,speed,ram,ram2,rspeed,graphics,wired,wireless,os,deploy,checkup))

「/usr/lib/pymodules/python2.7/MySQLdb /cursors.py「,第1行74,在執行 self.errorhandler(self,exc,value)

文件「/usr/lib/pymodules/python2.7/MySQLdb/connections。PY」 36行,在defaulterrorhandler 提高errorclass,errorvalue

OperationalError:(1048, 「列 '用戶' 不能爲空」)

+0

最終的領域會可能是大約3-5寬(水平),和2-4深(即垂直) –

回答

2

更有效的方式來做到這一點:

<style> 

fieldset { 
    overflow: hidden; 
    margin-bottom: 5px; 
    display: inline-block; 
    width: 270px; 
} 

label { float: left; width: 120px; } 

input { width: 120px; } 

</style> 

<fieldset> 
    <label for="username">Username:</label> 
    <input type="text" id="username" /> 
</fieldset> 
<fieldset> 
    <label for="mname">Machine Name:</label> 
    <input type="text" id="mname" /> 
</fieldset> 
<fieldset> 
    <label for="os">OS:</label> 
    <input type="text" id="os" /> 
</fieldset> 
<fieldset> 
    <label for="model">Model:</label> 
    <input type="text" id="model" /> 
</fieldset> 

這樣,您還將重點領域那麼他們的標籤被點擊焦點光標

例:http://jsfiddle.net/6SVp7/1/

+0

這會取代表格的需要嗎?我會告訴你我目前的代碼。 –

+0

儘管如此,對嗎? –

+1

是的。你可以這樣做:http://jsfiddle.net/6SVp7/2/(例如開始新行,把class =「newline」添加到字段集) –

相關問題