上图中的最上面的三个按钮效果是通过css改变input标签来实现的,下面两个则是两个a标签,通过css来改变相应的样式,下面我们一起来学习一下上面的效果。
一、按钮设置:
在界面上添加三个input按钮:
css代码:
input{ width: 100px; height: 40px; border: none; background-image: url(button/btn.png);}
这样的效果存在的问题就是,我们的背景是固定的,不能随我们的内容增加而改变。
二、a标签的效果的显示:
a标签:
按钮
css代码:
a{ text-decoration: none; padding-left: 15px; display: inline-table; width: 100px; height: 40px; line-height: 40px; background: url(button/btn_bg.png);} a:HOVER{ background-position: 0 -80px;} a span{ display: inline-table; height: 40px; padding-right: 15px; color: #fff; background: url(button/btn_bg.png) right -40px;} a:HOVER span{ background-position: right -120px;}
三、css3新增的圆角设置属性实现上述效果:
a标签:
按钮
css新增圆角属性:
.button{ display: inline-table; height: 40px; color: #fff; padding: 0 15px; background: url(button/css3_btn_bg.png); text-align: center; border: 1px solid #3c8134; border-radius: 5px} .button:HOVER { background-position: 0 -40px;}
四、最后我们通过一个菜单效果的案例结束本篇的总结:
效果图:
界面代码:
首页 最新产品 内部新闻 联系我们
css代码:
body ul li {margin: 0px; padding: 0px; font-size: 12px; }ul { list-style-type: none; height: 27px; width:500px;border-bottom:2px solid #21530C}li { float: left; }a{display:inline-block;height:27px;line-height:27px;text-decoration:none;padding-left:9px;color:#000;margin-right:10px;}a span{display:inline-block;height:27px;padding-right:9px;}a:hover{ background:url(button/left.jpg) no-repeat ;}a:hover span{ background:url(button/right.jpg) no-repeat right #21530C;color:#fff;}
好了到这里我们关于水晶按钮的实现,就为大家分享完毕了,代码这里面关于css代码都是最基本的,相信大家应该没有什么困难。如果你有什么好的想法,请留言交流。
查看更多关于水晶按钮_html/css_WEB-ITnose的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did107609