用css制作表單并體(tǐ)驗親和力

發布時間:2007年02月07日      浏覽次數:2479 次
對于表單,很常用。但是在web standard建站的時候,他的排版往往讓人遺忘,到了真正用到的時候就發現讓人頭疼,當然我(wǒ)(wǒ)也遇到過。我(wǒ)(wǒ)現在要介紹一(yī)個用<fieldset></label>标簽制作漂亮而且具體(tǐ)親和力的表單的方法。
基本的xHTML:
<h3>已注冊用戶登錄</h3>
<form action="" method="post" name="apLogin" id="apLogin">
<fieldset>
<legend>用戶登錄</legend>
<div>
<label for="Name">用戶名</label>
<input type="text" name="Name" id="Name" size="18" maxlength="30" /><br />
</div>
<div>
<label for="password">密碼</label>
<input type="password" name="password" id="password" size="18" maxlength="15" /><br />
</div>
<div class="cookiechk">
<label><input type="checkbox" name="CookieYN" id="CookieYN" value="1" /> <a href="20170711122112.html" title="選擇是否記錄您的信息">記住我(wǒ)(wǒ)</a></label>
<input name="login791" type="submit" class="buttom" value="登錄" />
</div>
<div class="forgotpass"><a href="20170711122112.html">您忘記密碼?</a></div>
</fieldset>
</form>
看了代碼,發現标單描述文字都在<label></label>中(zhōng),隻要讓<label></label>标簽浮動左對齊,fieldset包含的<div>清除浮動,就可以實現我(wǒ)(wǒ)們常見的那類布局。
下(xià)面是基本的CSS:
fieldset label {
float:left;
width:120px;
text-align:right;
padding:4px;
margin:1px;
}
fieldset div {
clear:left;
margin-bottom:2px;
}
運行代碼框
<!DOCTYPE <a href="http://www.blue1000.com/bkhtml/c22/" title="HTML/JavaScript教程">HTML</a> PUBLIC "-//W3C//DTD X<a href="http://www.blue1000.com/bkhtml/c22/" title="HTML/JavaScript教程">HTML</a> 1.0 Strict//EN" "http://www.w3.org/TR/x<a href="http://www.blue1000.com/bkhtml/c22/" title="HTML/JavaScript教程">HTML</a>1/DTD/x<a href="http://www.blue1000.com/bkhtml/c22/" title="HTML/JavaScript教程">HTML</a>1-strict.dtd">
<<a href="http://www.blue1000.com/bkhtml/c22/" title="HTML/JavaScript教程">HTML</a> <a href="http://www.blue1000.com/bkhtml/c21/" title="XML教程">XML</a>ns="http://www.w3.org/1999/x<a href="http://www.blue1000.com/bkhtml/c22/" title="HTML/JavaScript教程">HTML</a>">
<head>
<meta http-equiv="Content-Type" content="text/<a href="http://www.blue1000.com/bkhtml/c22/" title="HTML/JavaScript教程">HTML</a>; charset=gb2312" />
<title>Form demo</title>
<style type="text/<a href="http://www.blue1000.com/bkhtml/c23/" title="CSS教程">CSS</a>">
<!--
body {
      font-family: Arial, Helvetica, sans-serif;
      font-size:12px;
      color:#666666;
      background:#fff;
      text-align:center;
}
* {
      margin:0;
      padding:0;
}
a {
      color:#1E7ACE;
      text-decoration:none;      
}
a:hover {
      color:#000;
      text-decoration:underline;
}
h3 {
      font-size:14px;
      font-weight:bold;
}
pre,p {
      color:#1E7ACE;
      margin:4px;
}
input, select,textarea {
      padding:1px;
      margin:2px;
      font-size:11px;
}
.buttom{
      padding:1px 10px;
      font-size:12px;
      border:1px #1E7ACE solid;
      background:#D0F0FF;
}
#formwrapper {
      width:450px;
      margin:15px auto;
      padding:20px;
      text-align:left;
      border:1px #1E7ACE solid;
}
fieldset {
      padding:10px;
      margin-top:5px;
      border:1px solid #1E7ACE;
      background:#fff;
}
fieldset legend {
      color:#1E7ACE;
      font-weight:bold;
      padding:3px 20px 3px 20px;
      border:1px solid #1E7ACE;      
      background:#fff;
}
fieldset label {
      float:left;
      width:120px;
      text-align:right;
      padding:4px;
      margin:1px;
}
fieldset div {
      clear:left;
      margin-bottom:2px;
}
.enter{ text-align:center;}
.clear {
      clear:both;
}
-->
</style>
</head>
<body>
<div id="formwrapper">
<h3>已注冊用戶登錄</h3>
      <form action="" method="post" name="apLogin" id="apLogin">
      <fieldset>
            <legend>用戶登錄</legend>
            <div>
                  <label for="Name">用戶名</label>
                  <input type="text" name="Name" id="Name" size="18" maxlength="30" /><br />
            </div>
            <div>
                  <label for="pass<a href="http://www.blue1000.com/bkhtml/c117/" title="Word教程">word</a>">密碼</label>
                  <input type="pass<a href="http://www.blue1000.com/bkhtml/c117/" title="Word教程">word</a>" name="pass<a href="http://www.blue1000.com/bkhtml/c117/" title="Word教程">word</a>" id="pass<a href="http://www.blue1000.com/bkhtml/c117/" title="Word教程">word</a>" size="18" maxlength="15" /><br />
            </div>
            <div class="cookiechk">
                  <label><input type="checkbox" name="CookieYN" id="CookieYN" value="1" /> <a href="20170711122112.html" title="選擇是否記錄您的信息">記住我(wǒ)(wǒ)</a></label>
                  <input name="login791" type="submit" class="buttom" value="登錄" />
            </div>      
            <div class="forgotpass"><a href="20170711122112.html">您忘記密碼?</a></div>      
      </fieldset>
      </form><br />
      <h3>未注冊創建帳戶</h3>
      <form action="" method="post" name="apForm" id="apForm">
      <fieldset>
            <legend>用戶注冊</legend>
            <p><strong>您的電子郵箱不會被公布出去(qù),但是必須填寫.</strong> 在您注冊之前請先認真閱讀服務條款.</p>
            <div>
            <label for="Name">用戶名</label>
            <input type="text" name="Name" id="Name" value="" size="20" maxlength="30" />
            *(最多30個字符)<br />      
      </div>
            <div>
            <label for="Email">電子郵箱</label>
            <input type="text" name="Email" id="Email" value="" size="20" maxlength="150" /> *<br />      
      </div>      
            <div>
            <label for="pass<a href="http://www.blue1000.com/bkhtml/c117/" title="Word教程">word</a>">密碼</label>
            <input type="pass<a href="http://www.blue1000.com/bkhtml/c117/" title="Word教程">word</a>" name="pass<a href="http://www.blue1000.com/bkhtml/c117/" title="Word教程">word</a>" id="pass<a href="http://www.blue1000.com/bkhtml/c117/" title="Word教程">word</a>" size="18" maxlength="15" />
            *(最多15個字符)<br />
      </div>
            <div>
            <label for="confirm_pass<a href="http://www.blue1000.com/bkhtml/c117/" title="Word教程">word</a>">重複密碼</label>
            <input type="pass<a href="http://www.blue1000.com/bkhtml/c117/" title="Word教程">word</a>" name="confirm_pass<a href="http://www.blue1000.com/bkhtml/c117/" title="Word教程">word</a>" id="confirm_pass<a href="http://www.blue1000.com/bkhtml/c117/" title="Word教程">word</a>" size="18" maxlength="15" />
            *<br />
      </div>
            <div>
            <label for="AgreeToTerms">同意服務條款</label>
             <input type="checkbox" name="AgreeToTerms" id="AgreeToTerms" value="1" />
             <a href="20170711122112.html" title="您是否同意服務條款">先看看條款?</a> *      </div>            
            <div class="enter">
       <input name="create791" type="submit" class="buttom" value="提交" />
       <input name="Submit" type="reset" class="buttom" value="重置" />
      </div>
            <p><strong>* 在提交您的注冊信息時, 我(wǒ)(wǒ)們認爲您已經同意了我(wǒ)(wǒ)們的服務條款.<br />
       * 這些條款可能在未經您同意的時候進行修改.</strong></p>      
      </fieldset>
      </form>
</div>
</body>
</<a href="http://www.blue1000.com/bkhtml/c22/" title="HTML/JavaScript教程">HTML</a>>
[Ctrl+A 全部選擇 提示:你可先修改部分(fēn)代碼,再按運行]
交互部分(fēn)的設計
交互設計,親和力,用戶體(tǐ)驗,這些經常挂在設計師嘴邊的名詞倒是是做什麽的?我(wǒ)(wǒ)們不妨來嘗試一(yī)下(xià)!
1.表單内容設計合理性,這裏介紹的是帳戶登陸的交互界面,當然包涵已注冊和新用戶兩種人群,我(wǒ)(wǒ)們就設計出兩個選擇。
2.表單界面設計的親和力,布局,顔色,字體(tǐ),文字大(dà)小(xiǎo),行高等要素。我(wǒ)(wǒ)使用了
字體(tǐ): Arial, Helvetica, sans-serif
字體(tǐ)大(dà)小(xiǎo):12px 14px
顔色:#666666 #1E7ACE #000000 淡蘭色,灰色,黑色給用戶穩重安全的感覺
3.内容細節,比如記錄用戶信息,必要的提醒。
就這樣換位思考一(yī)下(xià)用戶的需求,就能做到基本的親和力,得到比較好的用戶體(tǐ)驗!要作到更完善的話(huà),你就需要去(qù)看看MSN Google等國外(wài)大(dà)型交互網站是怎麽做的了!
文章來源:http://www.blue1000.com/bkhtml/2006-04/44862.htm
免責聲明:本站相關技術文章信息部分(fēn)來自網絡,目的主要是傳播更多信息,如果您認爲本站的某些信息侵犯了您的版權,請與我(wǒ)(wǒ)們聯系,我(wǒ)(wǒ)們會即時妥善的處理,謝謝合作!