Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

[分享] 使用fieldset、label标签制作form表单

[复制链接]
luoyangwang 发表于 2007-10-19 11:13:25 | 显示全部楼层 |阅读模式
对于表单,是网页中非常常用的元素。但是在web standard建站的时候,他的排版容易人遗忘,到了真正用到的时候就发现让人头疼,当然我也遇到过。我现在要介绍一个用<fieldset></label>标签制作漂亮而且具体亲和力的表单的方法。
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  5. <title>www.52css.com</title>
  6. <style type="text/css">
  7. <!--
  8. body {
  9.         font-family: Arial, Helvetica, sans-serif;
  10.         font-size:12px;
  11.         color:#666666;
  12.         background:#fff;
  13.         text-align:center;

  14. }

  15. * {
  16.         margin:0;
  17.         padding:0;
  18. }

  19. a {
  20.         color:#1E7ACE;
  21.         text-decoration:none;       
  22. }

  23. a:hover {
  24.         color:#000;
  25.         text-decoration:underline;
  26. }
  27. h3 {
  28.         font-size:14px;
  29.         font-weight:bold;
  30. }

  31. pre,p {
  32.         color:#1E7ACE;
  33.         margin:4px;
  34. }
  35. input, select,textarea {
  36.         padding:1px;
  37.         margin:2px;
  38.         font-size:11px;
  39. }
  40. .buttom{
  41.         padding:1px 10px;
  42.         font-size:12px;
  43.         border:1px #1E7ACE solid;
  44.         background:#D0F0FF;
  45. }
  46. #formwrapper {
  47.         width:450px;
  48.         margin:15px auto;
  49.         padding:20px;
  50.         text-align:left;
  51.         border:1px #1E7ACE solid;
  52. }

  53. fieldset {
  54.         padding:10px;
  55.         margin-top:5px;
  56.         border:1px solid #1E7ACE;
  57.         background:#fff;
  58. }

  59. fieldset legend {
  60.         color:#1E7ACE;
  61.         font-weight:bold;
  62.         padding:3px 20px 3px 20px;
  63.         border:1px solid #1E7ACE;       
  64.         background:#fff;
  65. }

  66. fieldset label {
  67.         float:left;
  68.         width:120px;
  69.         text-align:right;
  70.         padding:4px;
  71.         margin:1px;
  72. }

  73. fieldset div {
  74.         clear:left;
  75.         margin-bottom:2px;
  76. }

  77. .enter{ text-align:center;}
  78. .clear {
  79.         clear:both;
  80. }

  81. -->
  82. </style>
  83. </head>

  84. <body>
  85. <div id="formwrapper">

  86. <h3>已注册用户登录</h3>
  87.         <form action="" method="post" name="apLogin" id="apLogin">
  88.         <fieldset>
  89.                 <legend>用户登录</legend>
  90.                 <div>
  91.                         <label for="Name">用户名</label>
  92.                         <input type="text" name="Name" id="Name" size="18" maxlength="30" />

  93.                 </div>
  94.                 <div>
  95.                         <label for="password">密码</label>
  96.                         <input type="password" name="password" id="password" size="18" maxlength="15" />

  97.                 </div>
  98.                 <div class="cookiechk">
  99.                         <label><input type="checkbox" name="CookieYN" id="CookieYN" value="1" /> <a href="#" title="选择是否记录您的信息">记住我</a></label>
  100.                         <input name="login791" type="submit" class="buttom" value="登录" />
  101.                 </div>       
  102.                 <div class="forgotpass"><a href="#">您忘记密码?</a></div>       
  103.         </fieldset>
  104.         </form>

  105.         <h3>未注册创建帐户</h3>
  106.         <form action="" method="post" name="apForm" id="apForm">
  107.         <fieldset>
  108.                 <legend>用户注册</legend>
  109.                 <p><strong>您的电子邮箱不会被公布出去,但是必须填写.</strong> 在您注册之前请先认真阅读服务条款.</p>
  110.                 <div>
  111.                 <label for="Name">用户名</label>
  112.                 <input type="text" name="Name" id="Name" value="" size="20" maxlength="30" />
  113.                 *(最多30个字符)
  114.        
  115.         </div>
  116.                 <div>
  117.                 <label for="Email">电子邮箱</label>
  118.                 <input type="text" name="Email" id="Email" value="" size="20" maxlength="150" /> *
  119.        
  120.         </div>       
  121.                 <div>
  122.                 <label for="password">密码</label>
  123.                 <input type="password" name="password" id="password" size="18" maxlength="15" />
  124.                 *(最多15个字符)

  125.         </div>
  126.                 <div>
  127.                 <label for="confirm_password">重复密码</label>
  128.                 <input type="password" name="confirm_password" id="confirm_password" size="18" maxlength="15" />
  129.                 *


  130.         </div>
  131.                 <div>
  132.                 <label for="AgreeToTerms">同意服务条款</label>
  133.                    <input type="checkbox" name="AgreeToTerms" id="AgreeToTerms" value="1" />
  134.                    <a href="#" title="您是否同意服务条款">先看看条款?</a> *        </div>               
  135.                 <div class="enter">
  136.             <input name="create791" type="submit" class="buttom" value="提交" />
  137.             <input name="Submit" type="reset" class="buttom" value="重置" />
  138.         </div>

  139.                 <p><strong>* 在提交您的注册信息时, 我们认为您已经同意了我们的服务条款.

  140.             * 这些条款可能在未经您同意的时候进行修改.</strong></p>       
  141.         </fieldset>
  142.         </form>
  143. </div>
  144. </body>
  145. </html>
复制代码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2025-2-26 08:08 , Processed in 0.022177 second(s), 3 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表