--编辑--我没有看到原始帖子中的链接.抱歉的!将try 重写以反映实际问题
StopDesign在这个here上有一个很好的帖子.[edit 20091107] These were released as part of the 101: see the 102.
基本上,自定义按钮是使用简单的CSS创建的.
他最初使用了9个表来获得效果:
但后来,他在顶部和底部边框上使用了一个简单的1px左右边距来实现同样的效果.
渐变是通过使用三个层来伪造的:
所有代码都可以在Custom Buttons 3.1页找到.(虽然没有图像的渐变仅在Firefox和Safari中有效)
循序渐进的说明
1-插入以下CSS:
/* Start custom button CSS here
---------------------------------------- */
.btn {
display:inline-block;
background:none;
margin:0;
padding:3px 0;
b或der-width:0;
overflow:visible;
font:100%/1.2 Arial,Sans-serif;
text-dec或ation:none;
col或:#333;
}
* html button.btn {
padding-bottom:1px;
}
/* Immediately below is a temp或ary hack to serve the
following margin values only to Gecko browsers
Gecko browsers add an extra 3px of left/right
padding to button elements which can't be overriden.
Thus, we use -3px of left/right margin to overcome this. */
html:not([lang*=""]) button.btn {
margin:0 -3px;
}
.btn span {
background:#f9f9f9;
z-index:1;
margin:0;
padding:3px 0;
b或der-left:1px solid #ccc;
b或der-right:1px solid #bbb;
}
* html .btn span {
padding-top:0;
}
.btn span span {
background:none;
position:relative;
padding:3px .4em;
b或der-width:0;
b或der-top:1px solid #ccc;
b或der-bottom:1px solid #bbb;
}
.btn b {
background:#e3e3e3;
position:absolute;
z-index:2;
bottom:0;
left:0;
width:100%;
overflow:hidden;
height:40%;
b或der-top:3px solid #eee;
}
* html .btn b {
top:1px;
}
.btn u {
text-dec或ation:none;
position:relative;
z-index:3;
}
/* pill classes only needed if using pill style buttons ( LEFT | CENTER | RIGHT ) */
button.pill-l span {
b或der-right-width:0;
}
button.pill-l span span {
b或der-right:1px solid #ccc;
}
button.pill-c span {
b或der-right-style:none;
b或der-left-col或:#fff;
}
button.pill-c span span {
b或der-right:1px solid #ccc;
}
button.pill-r span {
b或der-left-col或:#fff;
}
/* only needed if implementing separate hover state f或 buttons */
.btn:hover span, .btn:hover span span {
curs或:pointer;
b或der-col或:#9cf !imp或tant;
col或:#000;
}
/* use if one button should be the 'primary' button */
.primary {
font-weight:bold;
col或:#000;
}
2-使用以下方式之一调用它(更多信息可在上面的链接中找到)
<a href="#" class="btn"><span><span><b> </b><u>button</u></span></span></a>
或
<button type="button" class="btn"><span><span><b> </b><u>button</u></span></span></button>