- 编辑 - 我没有看到原始帖子中的链接。对不起!将尝试重写以反映实际问题
StopDesign 在这方面有一篇很棒的文章here http://stopdesign.com/archive/2009/02/04/recreating-the-button.html. [编辑 20091107] 这些是作为闭包库 http://code.google.com/closure/: 参见按钮演示 http://closure-library.googlecode.com/svn/trunk/closure/goog/demos/button.html.
基本上他的自定义按钮shows http://stopdesign.com/eg/buttons/3.0/code.html使用简单的 CSS 创建。
He originally used 9 tables to get the effect:
但后来他在上下边框上使用了简单的1px左右边距来达到同样的效果。
The gradient is faked by using three layers:
所有代码都可以在以下位置找到自定义按钮 3.1 http://stopdesign.com/eg/buttons/3.1/code.html页。 (虽然没有图像的渐变仅适用于 Firefox 和 Safari)
分步说明
1 - 插入以下 CSS:
/* Start custom button CSS here
---------------------------------------- */
.btn {
display:inline-block;
background:none;
margin:0;
padding:3px 0;
border-width:0;
overflow:visible;
font:100%/1.2 Arial,Sans-serif;
text-decoration:none;
color:#333;
}
* html button.btn {
padding-bottom:1px;
}
/* Immediately below is a temporary 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;
border-left:1px solid #ccc;
border-right:1px solid #bbb;
}
* html .btn span {
padding-top:0;
}
.btn span span {
background:none;
position:relative;
padding:3px .4em;
border-width:0;
border-top:1px solid #ccc;
border-bottom:1px solid #bbb;
}
.btn b {
background:#e3e3e3;
position:absolute;
z-index:2;
bottom:0;
left:0;
width:100%;
overflow:hidden;
height:40%;
border-top:3px solid #eee;
}
* html .btn b {
top:1px;
}
.btn u {
text-decoration:none;
position:relative;
z-index:3;
}
/* pill classes only needed if using pill style buttons ( LEFT | CENTER | RIGHT ) */
button.pill-l span {
border-right-width:0;
}
button.pill-l span span {
border-right:1px solid #ccc;
}
button.pill-c span {
border-right-style:none;
border-left-color:#fff;
}
button.pill-c span span {
border-right:1px solid #ccc;
}
button.pill-r span {
border-left-color:#fff;
}
/* only needed if implementing separate hover state for buttons */
.btn:hover span, .btn:hover span span {
cursor:pointer;
border-color:#9cf !important;
color:#000;
}
/* use if one button should be the 'primary' button */
.primary {
font-weight:bold;
color:#000;
}
2 - 使用以下方式之一来调用它(更多内容可以在上面的链接中找到)
<a href="#" class="btn"><span><span><b> </b><u>button</u></span></span></a>
or
<button type="button" class="btn"><span><span><b> </b><u>button</u></span></span></button>