对于仅图标按钮和带有白色图标的默认样本,我使用此 CSS。
示例
一个带有一个非常宽的图标和一个圆形图标。 Demo
<button class="fa fa-address-card ui-btn ui-btn-icon-notext ui-corner-all"/>
<button class="fa fa-plus-circle ui-btn ui-btn-icon-notext ui-corner-all"/>
CSS
.ui-btn.fa.ui-btn-icon-notext
{
text-indent: 0px;
color: #fff;
background-color: #acacac;
padding: 0.1em;
font-size: 0.8985em;
height: 1.75em;
width: 1.75em;
/* use inset box-shadow to simulate black background (:after) with opacity, which did blend white fa icons
default outset black shadow*/
box-shadow: inset 0 0 0px 0.21em #f6f6f6, 0 1px 3px rgba(0,0,0,.15);
text-shadow: none;
}
.ui-btn.fa.ui-btn-icon-notext:focus
{
box-shadow: inset 0 0 0px 0.21em #f6f6f6, 0 0 12px #38c; /* inset and default outset focus shadow */
}
.ui-btn.fa.ui-btn-icon-notext:hover
{
box-shadow: inset 0 0 0px 0.21em #ededed, 0 1px 3px rgba(0,0,0,.15);; /* simulate default hover with box shadow, default outset black shadow */
}
.ui-btn.fa.ui-btn-icon-notext:after
{
background-color: transparent;
content: "";
}
背景:
最初的方法非常简单,但只允许黑色或深色字体的真棒图标,因为 jquery 使用以下规则来呈现图标。白色图标将与此 after 透明背景融为一体。我使用 inset box-shadow 来避免这种情况。
.ui-btn-icon-notext:after
{
background-color:#666;
background-color:rgba(0,0,0,.3);
}