
<input type="submit" name="Submit" value="提 交">
<input type="reset" name="Reset" value="重 写">
<input type="button" name="butto11" value="点我试试" onclick="alert('谢谢您点击!')" >

<input type="submit" name="Submit" value="提 交" style=" font-size: 12px; background: #CCCCFF; border-width: thin thin thin thin; border-color: #CCCCFF #CCCCCC #CCCCCC #CCCCFF">
从源代码中可以看出,按钮的基本参数设置没变,只是加了一段CSS代码,正是这段CSS代码改变了按钮的外观风格。在这段CSS代码中,不仅重新设置了表单按钮的背景色和字号大小,而且还对按钮的边框线进行了设置,把上边框线、左边框线设置浅一点的颜色,而把下边框线、右边框线设置深一点的颜色,其目的是使表单按钮产生立体效果。当然,你可以任意改变CSS代码中颜色,以使按钮的颜色与所在网页的颜色协调。
鼠标不在按钮上
鼠标在按钮上<style type="text/css">
<!--
.style1 { font-size: 12px; background: #CCCCFF; border-width: thin thin thin thin; border-color: #CCCCFF #CCCCCC #CCCCCC #CCCCFF}
.style2 { font-size: 12px; font-weight: bold; background: #CCFFCC; border-width: thin medium medium thin; border-color: #CCFF99 #999999 #999999 #CCFF99}
-->
</style>
<input type="submit" name="Submit" value="提 交" onmouseover="this.className='style2'" onmouseout="this.className='style1'" class="style1">
从上面的代码中可看到,当鼠标移到按钮上,也就是onmuseover事件发生,那么按钮将采用style2甩定义的外观样式;当鼠标移开按钮时,也就是 onmuseout事件发生,那么按钮就采用style1所定义的外观样式,从而实现了动态变化的目的。后面那个class="style1"的作用是当 onmouseover、onmouseout这两个事件都没发生时,采用style1所定义的外观样式,从而保持了按钮外观的一致性。
二、动态变换图像按钮
鼠标不在按钮上
鼠标在按钮上1、作按钮背景的图片最好用具透明背景的gif图片,这样可以做出各种各样形状的按钮,将具有很强的个性;
2、背景图片的大小要与按钮的大小一致,否则,由于背景的平铺填充,将使按钮面目全非。<style type="text/css">
<!--
.style3 { font-size: 12px; background: url(image/buttonbg1.gif); border: 0px; width: 60px; height: 22px}
.style4 { font-size: 12px; font-weight: bold; background: url(image/buttonbg2.gif); border: 0px 0; width: 60px; height: 22px}
-->
</style>
<input type="submit" name="Submit2" value="提 交" onmouseover="this.className='style4'" onmouseout="this.className='style3'" class="style3">
从按钮代码可看出它与例一的按钮代码完全相同,但本例的CSS代码与例一有较大的区别,这里要注意:url后面的括号中是按钮背景图片的地址,也就是含路径的图片文件名,你在实际制作时要把它改成图片的实际地址。内容来自中国站长资讯网(www.chinahtml.com)