职业IT人-IT人生活圈

 找回密码
 成为会员
搜索
查看: 3345|回复: 0

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

[复制链接]
难得糊涂 发表于 2007-8-20 09:00 | 显示全部楼层 |阅读模式
今天把公司平台中前设计师做的按钮部分重新设计了下,原先他使用的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=&#39;button-style02&#39;\" onmouseout=\"this.className=&#39;button-style01&#39;\" class=\"button-style01\" style=\"width:70px;\" />

<a href=\"#\" onmouseover=\"this.className=&#39;button-style02&#39;\" onmouseout=\"this.className=&#39;button-style01&#39;\" class=\"button-style01\">Join Free</a>
下图为效果图:
您需要登录后才可以回帖 登录 | 成为会员

本版积分规则

QQ|手机版|小黑屋|网站帮助|职业IT人-IT人生活圈 ( 粤ICP备12053935号-1 )|网站地图
本站文章版权归原发布者及原出处所有。内容为作者个人观点,并不代表本站赞同其观点和对其真实性负责,本站只提供参考并不构成任何投资及应用建议。本站是信息平台,网站上部分文章为转载,并不用于任何商业目的,我们已经尽可能的对作者和来源进行了通告,但是能力有限或疏忽造成漏登,请及时联系我们,我们将根据著作权人的要求立即更正或者删除有关内容。

GMT+8, 2024-5-15 17:44 , Processed in 0.116203 second(s), 20 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表