网页设计之5种简单的XHTML网页表单
2000-01-01 00:00
666 查看
网页设计之5中简单的XHTML网页表单。
技术1:标签三明治
将输入框,选择框和文本框全部包含进 label 元素,并全部设置为块级元素。将单选按钮和多选框显示方式设置为 inline 以便于它们在同一行出现。如果你比较喜欢 label 和单选按钮/多选框出现在不同行,可以选择不把它包含在 label 里面,或者使用硬换行处理。
每种情况都在下面展示了。
当这些看起来比较时髦的时候,W3C 事实上已经含蓄地展示了他们的 label 例子。
主要好处:简单
代码:
label, input, select, textarea {display: block;}
label {margin-bottom: 10px;}
input[type="radio"], input[type="checkbox"] {display: inline;}
<form> <fieldset>
<legend>Contact Form</legend>
<label for="name">
Name</label>
<input id="name" name="name" size="20" />
<label for="email">Email</label>
<input id="email" name="email" size="20" />
<label for=" Choices"> Choices (radio) — <em>wrapped label</em></label>
<input name=" Choice" type="radio" /> Choice 1
<input name=" Choice" type="radio" /> Choice 2
<input name=" Choice" type="radio" /> Choice 3
<label style="margin-bottom: 0pt;" for=" Choices2"> Choices (checkbox) — <em>non-wrapped label, margin reset</em></label>
<input name=" Choice2" type="checkbox" /> Choice 1
<input name=" Choice2" type="checkbox" /> Choice 2
<input name=" Choice2" type="checkbox" /> Choice 3
<div style="height: 10px;"><!-- just to split the demo up --></div>
<label for=" Choices3"> Choices (checkbox) — <em>wrapped, hard line-break</em></label>
<input name=" Choice3" type="checkbox" /> Choice 1
<input name=" Choice3" type="checkbox" /> Choice 2
<input name=" Choice3" type="checkbox" /> Choice 3
<label for="dropdown">
Question</label>
<select id="dropdown"> <optgroup label="Group of Options"></optgroup> <option>Option 1</option> <option>Option 2</option> <option>Option 3</option> </select>
<label for="message">
Message
<textarea cols="36" rows="12" name="message"></textarea>
</label>
<input type="submit" value="send it" />
</fieldset>
</form>
运行结果:
#expamle1 label,#expamle1 input,#expamle1 select,#expamle1 textarea {display: block;}
#expamle1 label {margin-bottom: 10px;}
#expamle1 input[type="radio"],#expamle1 input[type="checkbox"] {display: inline;}
技术2:懒人
许多开发者采用了这种不正统但是快速简单(用换行隔断标记)的方法。虽然能运行,但是对你的 css 能力有害,因为你不需要任何 css 去实现它。
主要好处:快速
代码:
<form> <fieldset>
<legend>Contact Form</legend>
<label for="name">Name</label>
<input id="name" name="name" size="20" /> <label for="email">Email</label>
<input id="email" name="email" size="20" /> <label for=" Choices"> Choices (radio)</label>
<input name=" Choice" type="radio" /> Choice 1
<input name=" Choice" type="radio" /> Choice 2
<input name=" Choice" type="radio" /> Choice 3
<label for=" Choices3"> Choices (checkbox)</label>
<input name=" Choice3" type="checkbox" /> Choice 1
<input name=" Choice3" type="checkbox" /> Choice 2
<input name=" Choice3" type="checkbox" /> Choice 3
<label for="dropdown">Question</label>
<select id="dropdown"> <optgroup label="Group of Options"></optgroup> <option>Option 1</option> <option>Option 2</option> <option>Option 3</option> </select>
<label for="message">Message</label>
<textarea cols="36" rows="12" name="message"></textarea>
<input type="submit" value="send it" />
</fieldset>
</form>
运行结果:
上一页12 下一页
技术1:标签三明治
将输入框,选择框和文本框全部包含进 label 元素,并全部设置为块级元素。将单选按钮和多选框显示方式设置为 inline 以便于它们在同一行出现。如果你比较喜欢 label 和单选按钮/多选框出现在不同行,可以选择不把它包含在 label 里面,或者使用硬换行处理。
每种情况都在下面展示了。
当这些看起来比较时髦的时候,W3C 事实上已经含蓄地展示了他们的 label 例子。
主要好处:简单
代码:
label, input, select, textarea {display: block;}
label {margin-bottom: 10px;}
input[type="radio"], input[type="checkbox"] {display: inline;}
<form> <fieldset>
<legend>Contact Form</legend>
<label for="name">
Name</label>
<input id="name" name="name" size="20" />
<label for="email">Email</label>
<input id="email" name="email" size="20" />
<label for=" Choices"> Choices (radio) — <em>wrapped label</em></label>
<input name=" Choice" type="radio" /> Choice 1
<input name=" Choice" type="radio" /> Choice 2
<input name=" Choice" type="radio" /> Choice 3
<label style="margin-bottom: 0pt;" for=" Choices2"> Choices (checkbox) — <em>non-wrapped label, margin reset</em></label>
<input name=" Choice2" type="checkbox" /> Choice 1
<input name=" Choice2" type="checkbox" /> Choice 2
<input name=" Choice2" type="checkbox" /> Choice 3
<div style="height: 10px;"><!-- just to split the demo up --></div>
<label for=" Choices3"> Choices (checkbox) — <em>wrapped, hard line-break</em></label>
<input name=" Choice3" type="checkbox" /> Choice 1
<input name=" Choice3" type="checkbox" /> Choice 2
<input name=" Choice3" type="checkbox" /> Choice 3
<label for="dropdown">
Question</label>
<select id="dropdown"> <optgroup label="Group of Options"></optgroup> <option>Option 1</option> <option>Option 2</option> <option>Option 3</option> </select>
<label for="message">
Message
<textarea cols="36" rows="12" name="message"></textarea>
</label>
<input type="submit" value="send it" />
</fieldset>
</form>
运行结果:
#expamle1 label,#expamle1 input,#expamle1 select,#expamle1 textarea {display: block;}
#expamle1 label {margin-bottom: 10px;}
#expamle1 input[type="radio"],#expamle1 input[type="checkbox"] {display: inline;}
技术2:懒人
许多开发者采用了这种不正统但是快速简单(用换行隔断标记)的方法。虽然能运行,但是对你的 css 能力有害,因为你不需要任何 css 去实现它。
主要好处:快速
代码:
<form> <fieldset>
<legend>Contact Form</legend>
<label for="name">Name</label>
<input id="name" name="name" size="20" /> <label for="email">Email</label>
<input id="email" name="email" size="20" /> <label for=" Choices"> Choices (radio)</label>
<input name=" Choice" type="radio" /> Choice 1
<input name=" Choice" type="radio" /> Choice 2
<input name=" Choice" type="radio" /> Choice 3
<label for=" Choices3"> Choices (checkbox)</label>
<input name=" Choice3" type="checkbox" /> Choice 1
<input name=" Choice3" type="checkbox" /> Choice 2
<input name=" Choice3" type="checkbox" /> Choice 3
<label for="dropdown">Question</label>
<select id="dropdown"> <optgroup label="Group of Options"></optgroup> <option>Option 1</option> <option>Option 2</option> <option>Option 3</option> </select>
<label for="message">Message</label>
<textarea cols="36" rows="12" name="message"></textarea>
<input type="submit" value="send it" />
</fieldset>
</form>
运行结果:
上一页12 下一页
相关文章推荐
- 简单的网页验证码设计——学习笔记
- 利用C语言实现POST数据包如此简单【模拟网页提交表单】
- 推荐25个非常优秀的网页表单设计案例
- 网页设计中的常用表单设计技巧
- 30个非常时尚的网页联系表单设计优秀示例
- html网页设计简单登陆界面
- 利用C语言实现POST数据包如此简单【模拟网页提交表单】
- 网页设计基础教程最最简单的一个ppt
- 网页设计之简单注册页面
- 30个非常时尚的网页联系表单设计优秀示例
- 40多个漂亮的网页表单设计实例
- 推荐 10 款 CSS 框架,网页设计就是这么简单
- 经典网页设计:20例与众不同的网页联系表单设计
- 一个简单的登陆网页设计(JSP+MySQL+Tomcat)
- 练习HTML——简单的网页设计
- 网页设计关于表单输入框的技巧代码
- 网页设计之简单风格欣赏
- 浅议网页制作中的表单设计
- 设计自动获取网页和提交表单组件
- 表单设计器的简单思路