jquery-ui – 使用Font-Awesome扩展jQuery UI图标

前端之家收集整理的这篇文章主要介绍了jquery-ui – 使用Font-Awesome扩展jQuery UI图标前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想要一种使用Font-Awesome图标来扩展默认的jQuery UI图标的方法。如果可能,保持jQuery图标作为回退,因为Font-Awesome没有完整的覆盖。

jQuery UI示例:

  1. $("#muteAll").button({
  2. text: false,icons: {
  3. primary: "ui-icon-volume-on"
  4. }
  5. });

Font-Awesome替换/扩展示例:

  1. $("#muteAll").button({
  2. text: false,icons: {
  3. primary: "icon-volume-up"
  4. }
  5. });

我最接近的是:

  1. .ui-icon[class*=" icon-"] {
  2. background: none repeat scroll 0 0 transparent;
  3. left: 0;
  4. margin-left: 1px;
  5. text-indent: 0;
  6. }
@H_404_14@

解决方法

最后的解决方案的股票jQuery与我已经提出的注释:
  1. /* Allow Font Awesome Icons in lieu of jQuery UI and only apply when using a FA icon */
  2. .ui-icon[class*=" icon-"] {
  3. /* Remove the jQuery UI Icon */
  4. background: none repeat scroll 0 0 transparent;
  5. /* Remove the jQuery UI Text Indent */
  6. text-indent: 0;
  7. /* Bump it up - jQuery UI is -8px */
  8. margin-top: -0.5em;
  9. }
  10.  
  11. /* Allow use of icon-large to be properly aligned */
  12. .ui-icon.icon-large {
  13. margin-top: -0.75em;
  14. }
  15.  
  16. .ui-button-icon-only .ui-icon[class*=" icon-"] {
  17. /* Bump it - jQuery UI is -8px */
  18. margin-left: -7px;
  19. }

演示jsfiddle

@H_404_14@ @H_404_14@

猜你在找的jQuery相关文章