网页实例:用CSS制作带有样式的网页按钮

网页实例:用CSS制作带有样式的网页按钮

今天把公司平台中前设计师做的按钮部分重新设计了下,原先他使用的JS实现图片交替变化的方式,但那样的缺点是:占用了input里的ID属性,而且disabled也不能使用,不利于程序的设计制作。

按钮重新制作的思想:

1、实现触发与不触发之间的差别;

2、适用input和a;

3、多种浏览器下无差别。

按钮重新制作的过程:

1、利用不同样式实现触发与不触发之间的差别;

2、利用boder来模拟按钮阴影

以下代码在IE6、IE7、FF下测试正常!

CSS部分:

.button-style01{

 color:#5E7384;

 font-weight: bold;

 background:#CBDBE5;

 border-top:1px solid #f1f1f1;

 border-left:1px solid #f1f1f1;

 border-right:2px solid #666;

 border-bottom:2px solid #666;

 height: 25px

}

.button-style02{

 color:#fff;

 font-weight: bold;

 background: #859BAB;

 border:1px solid #f1f1f1;

 border-top:1px solid #f1f1f1;

 border-left:1px solid #f1f1f1;

 border-right:2px solid #666;

 border-bottom:2px solid #666;

 height: 25px

}

a.button-style01,a.button-style02 {

 display:block;

 height:22px;

 line-height:22px;

 vertical-align:middle;

 padding:0px 8px;

}

a.button-style01:link,a.button-style01:visited {

 text-decoration:none;

 color:#5E7384;

 border-top:1px solid #f1f1f1;

 border-left:1px solid #f1f1f1;

 border-right:2px solid #666;

 border-bottom:2px solid #666;

}

 

a.button-style02:hover,a.button-style02:active {

 text-decoration:none;

 color:#fff;

 border-top:1px solid #f1f1f1;

 border-left:1px solid #f1f1f1;

 border-right:2px solid #333;

 border-bottom:2px solid #333;

}

xhtml部分:

<input type=”submit” name=”login” id=”login” onclick=”myoffice.submit()” value=”Sign in” onmouseover=”this.className=’button-style02′” onmouseout=”this.className=’button-style01′” class=”button-style01″ style=”width:70px;” />

<a href=”#” onmouseover=”this.className=’button-style02′” onmouseout=”this.className=’button-style01′” class=”button-style01″>Join Free</a>

下图为效果图:

网页实例:用CSS制作带有样式的网页按钮

相关文章:

你感兴趣的文章:

标签云: