当前位置:编程学习 > html/css >>

HTML便签大全

1.1 字体样式的应用

  字体样式包括:字体族科(font-family)、字体风格(font-style)、字体变形(font-variant)、字体加粗(font-weight)、字体大小(font-size)、字体(font),具体的定义方法,在这里不详细讲述,可以参考它的资料。
  也许你已经注意到,按钮上的文字不漂亮,其实可以通过CSS字体样式来解决,同样地,其它的几个涉及到文字的表单项,例如,文本框、多行文本框、口令框、下拉选择框都可以应用字体样式。
  为了充分展示这些应用,下例特别设计了几种样式,在实际应用中,不必这么凌乱,灵活运用:

HTML代码

Java代码 
文本框里的文字是加粗的,大小是9pt,字体是宋体<br> 
<input type="text" name="formExam" size="10" maxlength="10" style="font-family:宋体; font-size: 12px; font-weight: bold" value="加粗"> 
<br>口令框文字是红色的<br> 
<input type="password" name="formExam3" style="font-size: 9pt; color: #FF0000" size="8" maxlength="8"> 
<br>下拉框文字颜色是红色的,字体是Verdana,大小是9pt<br> 
<select name="select" size="1" style="font-family:Verdana,Arial; font-size: 9pt; color: #FF0000"> 
<option value="2" selected>yesky.com</option> 
<option value="1">redidea.net</option> 
</select> 
<br>多行文本框了的字体是Verdana,有下划线,大小是9pt<br> 
<br>发送1和发送2按钮的文字不同,是因为发送1按钮使用了9pt的宋体文字,所以比较美观<br> 
<input type="submit" name="Submit" value="发送1" style="font-family:宋体; font-size: 9pt;"> <input type="submit" name="Submit" value="发送1" ><br> 
<TEXTAREA name="formExam2" cols="30" rows="3" style="font-family:Verdana, Arial; font-size: 9pt; color: #000099; text-decoration: underline" align=right>underline css style 

小结:只要我们对字体的样式熟悉了,就可以灵活多变,不一定要在标签里面使用style来定义,完全可以在<head>里定义,或者外部引用CSS文件,用到的时候引用一下就能达到预期的效果。

1.2 背景颜色和图像样式的应用

  有很多时候,网页由于颜色的搭配,不得不对表单的背景颜色和图像样式进行设计,背景颜色利用background-color属性,背景图像利用background-image属性,颜色和图像同样能够得到意想不到的效果。

 样例2: 表单元素的背景展示
Java代码 
HTML代码 
文本框背景是黑色的,字体是白色的<br> 
<input type="text" name="RedFld" size="10" maxlength="10" style="color: #FFFFFF; background-color: #000000"> 
<br>口令框背景是灰色的<br> 
<input type="password" name="RedFld3" size="10" maxlength="10" style="background-color: #999999"> 
<br>单选和复选按钮的背景是红色的<br> 
<input type="checkbox" name="checkbox" value="checkbox" style="background-color: #FF0000"> 
<input type="radio" name="radiobutton" value="radiobutton" style="background-color: #FF0000"> 
<br>下拉选择框的选项是丰富多彩的背景<br> 
<select name="select2" size="1"> 
<option selected style="background-color: #FF0000">yesky.com</option> 
<option style="background-color: #0000CC">redidea.com</option> 
<option style="background-color: #009900">chinabyte.com</option> 
<option style="background-color: #ff33cc">sina.com</option> 
<option style="background-color: #999999">sohu.com</option> 
</select> 
<br>多行文本框的背景是一个图像 
<br>submit1按钮的背景是黄色的<br> 
<input type="submit" name="Submit3" value="Submit1" style="background-color: #FF9900"> 
<br>submit2按钮的背景是一个图像<br> 
<input type="submit" name="Submit22" value="Submit2" style="background-image: url(attachments/month_200502/21_171412_2yq5bg.gif)"><br> 
<TEXTAREA name="RedFld2" cols="25" rows="3" wrap="VIRTUAL" style="background-image: url(attachments/month_200502/21_171412_2yq5bg.gif)"> 

小结:用好background-color属性和background-image属性,就可以设计很出“色”表单了。

1.3 边框样式的应用
  也许你觉得表单的边框过于死板,我们能否设计单线条,或者其它的边框样式呢?当然可以!
  和边框有关的属性有:边框式样border-style、上边框border-top、右边框border-right、下边框border-bottom、左边框border-left、边框颜色border-colr、边框宽度 border-width、上边框宽度border-top-width、右边框宽度border-right-width、下边框宽度border-bottom-width、左边框宽度border-left-width、边框 border,这里不作详细的讲述,请参考有关资料。

  样例3: 8种边框形式的展示

Java代码 
HTML代码 
 
<INPUT style="BORDER-RIGHT: #006600 1px dotted; BORDER-TOP: #006600 1px dotted; BORDER-LEFT: #006600 1px dotted; BORDER-BOTTOM: #006600 1px dotted" size=10 value=dotted name=RedF> 
 
<INPUT style="BORDER-RIGHT: 3px dashed; BORDER-TOP: 1px dashed; BORDER-LEFT: 3px dashed; BORDER-BOTTOM: 1px dashed" size=10 value=dashed name=RedF2> 
 
<INPUT style="BORDER-RIGHT: 3px double; BORDER-TOP: 3px double; BORDER-LEFT: 3px double; BORDER-BOTTOM: 3px double" size=10 value=double name=RedF3> 
 
<INPUT style="BORDER-RIGHT: 2px groove; BORDER-TOP: 2px groove; BORDER-LEFT: 2px groove; BORDER-BOTTOM: 2px groove" size=10 value=groove name=RedF4> <BR> 
 
<INPUT style="BORDER-RIGHT: 3px inset; BORDER-TOP: 3px inset; BORDER-LEFT: 3px inset; BORDER-BOTTOM: 3px inset" size=10 value=inset name=RedF5> 
 
<INPUT style="BORDER-RIGHT: 2px outset; BORDER-TOP: 2px outset; BORDER-LEFT: 2px outset; BORDER-BOTTOM: 2px outset" size=10 value=outset name=RedF6> 
 
<INPUT style="BORDER-RIGHT: 3px ridge; BORDER-TOP: 3px ridge; BORDER-LEFT: 3px ridge; BORDER-BOTTOM: 3px ridge" size=10 value=ridge name=RedF7> 
 
<INPUT style="BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; BORDER-LEFT: 1px solid; BORDER-BOTTOM: 1px solid" size=10 value=solid name=RedF8> <BR> 
 
<INPUT style="BORDER-RIGHT: #006600 1px dotted; BORDER-TOP: #006600 1px dotted; BORDER-LEFT: #006600 1px dotted; BORDER-BOTTOM: #006600 1px dotted" type=checkbox value=checkbox name=checkbox2> 复选 
<INPUT style="BORDER-RIGHT: #006600 1px dotted; BORDER-TOP: #006600 1px dotted; BORDER-LEFT: #006600 1px dotted; BORDER-BOTTOM: #006600 1px dotted" type=radio value=radiobutton name=radiobutton> 单选 
 
<INPUT style="BORDER-RIGHT: 3px double; BORDER-TOP: 3px double; BORDER-LEFT: 3px double; BORDER-BOTTOM: 3px double" type=submit value=发送 name=Submit4> 
 
<INPUT style="BORDER-RIGHT: 3px dashed; BORDER-TOP: 1px dashed; BORDER-LEFT: 3px dashed; BORDER-BOTTOM: 1px dashed" type=submit value=取消 name=Submit23> <BR> 
 
<TEXTAREA style="BORDER-RIGHT:

补充:web前端 , HTML/CSS  ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,