放大镜站内搜索:


您现在的位置:首页 > 电脑 > 网页制作 > 正文
简单form标准化实例——整体布局
学生王国 ∥ http://www.xswg.com 更新时间:2007年2月8日 调整字体:

</select>
</p>
<p>
<label for="yid" accesskey="Y"><span class="required">*</span> Yahoo! ID:</label>
<input type="text" value="" id="yid"> <span class="b">@yahoo.com</span><br />
<span class="explain">ID may consist of a-z, 0-9, underscores, and a single dot (.)</span>
</p>
<p>
<label for="pw" accesskey="P"><span class="required">*</span> Password:</label>
<input type="password" value="" id="pw" /><br />
<span class="explain">Six characters or more; capitalization matters!</span>
</p>
<p>
<label for="pw2" accesskey="R"><span class="required">*</span> Re-type password:</label>
<input type="password" value="" id="pw2"/>
</p>

<div id="submit">
<input type="submit" value="Submit" class="submit"/> <input type="reset" value="Reset" class="submit"/>
</div>

</form>

CSS部分:

* {
  margin:0;
  padding:0;
}

input,select {
   font-family:Arial, Helvetica, sans-serif;
   font-size: 12px;
}

.required {
  font:0.8em Verdana !important;
  color:#f68622;
}

.explain {
  color:#808080;
}

.b {
  font-weight:bold;
  font-size:12px;
}

.democss {
  font:11px/12px Arial, Helvetica, sans-serif;
  color:#333;
}

.democss p {
  width: 298px;
  clear: left;
  padding:4px;
  padding-left: 122px;
  text-align:left;
  height: 1%;
}

.democss label {
  float: left;
  margin-left: -122px;
  width: 110px;
  padding:4px 4px 0;
  text-align:right;
}

.democss input {
  width:180px;
}

.democss select#content {
  width:185px;
}

.democss input.submit {
  width:70px;
}

div#submit {
  width:298px;
  text-align:left;
  padding:4px;
  padding-left:122px;
}

* html .democss input,* html .democss select{
  margin-left: -3px; 
}

* html div#submit input{
  margin-left: 0px;
}

具体演示:

运行代码框

3、使用dl、dt、dd来布局

此属于发挥,练习的方法,当然图一的设计图还可以用其他更多的方法来布局,用dl、dt、dd来布局只为抛砖引玉。

  • dl:代表HTML自定义列表
  • dt:代表HTML自定义列表组
  • dd:HTML自定义列表描述

虽然说dl、dt、dd在语义上并不能很好的表现图一,但dl、dt、dd的布局特点依旧可以用来进行图一的布局,而且效果还不错,呵呵……

dt主要放label部分,dd主要放input或其他。

注意:和label布局一样,有IE的3px BUG。

下面我们具体来对图一的设计图进行整体布局:

XHTML部分:

<form id="demoform" class="democss" action="">

<dl>

6共  上一页 1 2 3 4 5 6 下一页


相关链接
简单form标准化实例——语义结构 (2007年2月8日)
来自:蓝色理想
编辑:
浏览:
评论查看全部评论
您的评论
姓名:
请您注意:
1.请遵守《中国互联网行业自律条款》及中华人民共和国其他各项有关法律法规。
2.严禁发表危害国家安全、损害国家利益、破坏民族团结、破坏国家宗教政策、破坏社会稳定、侮辱、诽谤、教唆、淫秽等内容的评论 。
3.用户需对自己在使用本站服务过程中的行为承担法律责任(直接或间接导致的)。
4.本站管理员有权保留或删除评论内容。
评论内容只代表网友个人观点,与本网站立场无关。