【发布时间】:2013-05-31 09:54:16
【问题描述】:
我正在尝试使用这种格式样式创建一个表单:
label a
[input text] SUBMIT
label b
[select]
label c
label from [input text] label to [input texŧ] SUBMIT
这是我的带有css代码的html:
<style type="text/css">
form {
width:460px;
}
form label {
font-size:12px;
color:#666;
cursor:auto !important;
}
form input[type=text] {
padding:5px;
height:30px;
line-height:30px;
width:370px;
color:#333;
font-size:14px;
}
form select {
padding:5px;
height:30px;
line-height:26px;
width:370px;
color:#333;
font-size:12px;
border:solid 1px #ccc;
overflow:hidden;
}
form input[type=submit] {
height:20px;
width:20px;
background: url("/mini_glass.png") no-repeat scroll 3px 3px transparent;
border:none;
cursor:pointer;
}
</style>
<div class="margin_top_20">
<form action="">
<div>
<div id="A">
<label>a</label>
<input name="q" value="" type="text">
<input value="" type="submit">
</div>
</div>
<div id="B">
<label>b</label>
<select></select>
</div>
<div id="C">
<label>c</label>
<div id="D">
<label>from</label>
<input name="from" value="" type="text" style="width:50px">
<label>to</label>
<input name="to" value="" type="text" style="width:50px">
<input value="" type="submit">
</div>
</div>
</form>
</div>
我认为问题在于我应该设置位置或浮动等属性,但我不明白如何设置。我应该对某些 div 使用 float:left 属性吗?属性的工作方式对我来说不是很清楚。
【问题讨论】:
-
您的表单几乎按照您的意愿布置,您只需要在标签 a、b 和 c 之后添加
<br /> -
如果您希望不同的提交只提交各自的字段,则需要使用多个
<form>元素。 -
我还建议您了解
block、inline和inline-block元素之间的区别,然后您将更好地了解何时需要float元素 -
谢谢@MadaraUchiha,很好的观察,我将使用两种形式。