CSS制作带有样式的网页按钮
按钮重新制作的思想:
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>