我想要一种方法来扩展带有Font-Awesome图标的默认jQuery UI图标。如果可能的话,将jQuery图标保留为后备,因为Font-Awesome没有完全覆盖。
jQuery UI示例:
$("#muteAll").button({
text: false,
icons: {
primary: "ui-icon-volume-on"
}
});
Font-Awesome替换/扩展示例:
$("#muteAll").button({
text: false,
icons: {
primary: "icon-volume-up"
}
});
我最接近的是:
.ui-icon[class*=" icon-"] {
background: none repeat scroll 0 0 transparent;
left: 0;
margin-left: 1px;
text-indent: 0;
}
答案 0 :(得分:22)
带有我注意到的注释的股票jQuery的最终解决方案:
/* Allow Font Awesome Icons in lieu of jQuery UI and only apply when using a FA icon */
.ui-icon[class*=" icon-"] {
/* Remove the jQuery UI Icon */
background: none repeat scroll 0 0 transparent;
/* Remove the jQuery UI Text Indent */
text-indent: 0;
/* Bump it up - jQuery UI is -8px */
margin-top: -0.5em;
}
/* Allow use of icon-large to be properly aligned */
.ui-icon.icon-large {
margin-top: -0.75em;
}
.ui-button-icon-only .ui-icon[class*=" icon-"] {
/* Bump it - jQuery UI is -8px */
margin-left: -7px;
}
演示jsfiddle
答案 1 :(得分:12)
这是@ Brombomb的solution但是对于FontAwesome 4.x图标:
/* Allow Font Awesome Icons in lieu of jQuery UI and only apply when using a FA icon */
.ui-icon[class*=" fa-"] {
/* Remove the jQuery UI Icon */
background: none repeat scroll 0 0 transparent;
/* Remove the jQuery UI Text Indent */
text-indent: 0;
/* Bump it up - jQuery UI is -8px */
margin-top: -0.5em;
}
/* Allow use of icon-large to be properly aligned */
.ui-icon.icon-large {
margin-top: -0.75em;
}
.ui-button-icon-only .ui-icon[class*=" fa-"] {
/* Bump it - jQuery UI is -8px */
margin-left: -7px;
}
答案 2 :(得分:0)
请检查http://www.dotcastle.com/blog/font-awesome-icons-for-jquery-mobile