文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>漂亮的CSS按钮

漂亮的CSS按钮

时间:2008-02-29  来源:yuyii

  效果: <STYLE> .bt { border:1px solid #000; background:#E8F3FD; padding:3px 5px 2px; } a.squarebutton{ background: transparent url("http://blogimg.chinaunix.net/blog/upfile2/080229163513.gif") no-repeat top left; display: block; float: left; font: normal 12px Arial; /* Change 12px as desired */ line- /* This value + 4px + 4px (top and bottom padding of SPAN) must equal height of button background (default is 23px) */ /* Height of button background height */ padding-left: 9px; /* Width of left menu image */ text-decoration: none; } a:link.squarebutton, a:visited.squarebutton, a:active.squarebutton{ color: #494949; /*button text color*/ } a.squarebutton span{ background: transparent url('http://blogimg.chinaunix.net/blog/upfile2/080229163535.gif') no-repeat top right; display: block; padding: 4px 9px 4px 0; /*Set 9px below to match value of 'padding-left' value above*/ } a.squarebutton:hover{ /* Hover state CSS */ background-position: bottom left; } a.squarebutton:hover span{ /* Hover state CSS */ background-position: bottom right; color: black; } .buttonwrapper{ overflow: hidden; width: 100%; } </STYLE> Submit Reset   图片源: square-blue-right.gif:     square-blue-left.gif:   CSS代码:  

a.squarebutton{
background: transparent url('media/square-blue-left.gif') no-repeat top left;
display: block;
float: left;
font: normal 12px Arial; /* Change 12px as desired */
line- /* This value + 4px + 4px (top and bottom padding of SPAN) must equal height of button background (default is 23px) */
/* Height of button background height */
padding-left: 9px; /* Width of left menu image */
text-decoration: none;
}

a:link.squarebutton, a:visited.squarebutton, a:active.squarebutton{
color: #494949; /*button text color*/
}

a.squarebutton span{
background: transparent url('media/square-blue-right.gif') no-repeat top right;
display: block;
padding: 4px 9px 4px 0; /*Set 9px below to match value of 'padding-left' value above*/
}

a.squarebutton:hover{ /* Hover state CSS */
background-position: bottom left;
}

a.squarebutton:hover span{ /* Hover state CSS */
background-position: bottom right;
color: black;
}

.buttonwrapper{ /* Container you can use to surround a CSS button to clear float */
overflow: hidden; /*See: http://www.quirksmode.org/css/clearing.html */
width: 100%;
}

HTML代码:

<div class="buttonwrapper">
<a class="squarebutton" href="#"><span>Submit</span></a>

<a class="squarebutton" href="#" style="margin-left: 6px"><span>Reset</span></a>
</div>

另外为了模拟BUTTON,还需要给A加上onclick事件,并且需要在自定义事件后加上return false。这样页面不会有个跳转到#的过程了。

更多内容参见:

http://www.dynamicdrive.com/style/

一个很好的网站,一些漂亮的资源能拿来直接用了。

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载