博客列表 >【CSS】字体图标-引入第三方字体和图标:阿里图标字体

【CSS】字体图标-引入第三方字体和图标:阿里图标字体

可乐随笔
可乐随笔原创
2022年11月27日 20:24:17389浏览

字体图标

1. 字体图标

  1. - 阿里图标 <https://www.icofont.cn>
  2. - Unicode, class
  3. /*=============================================
  4. = 一、Unicode =
  5. =============================================*/
  6. /* 1.安装自定义图标字体 */
  7. /* CDN 服务仅供平台体验和调试使用,平台不承诺服务的稳定性,企业客户需下载字体包自行发布使用并做好备份。 */
  8. @font-face {
  9. /* 字体名称 */
  10. font-family: 'iconfont'; /* Project id 3778676 */
  11. /* 字体文件路径,可以是远程的,也可以是本地的 */
  12. src: url('//at.alicdn.com/t/c/font_3778676_xrrqstydj5.woff2?t=1668742255577') format('woff2'),
  13. url('//at.alicdn.com/t/c/font_3778676_xrrqstydj5.woff?t=1668742255577') format('woff'),
  14. url('//at.alicdn.com/t/c/font_3778676_xrrqstydj5.ttf?t=1668742255577') format('truetype');
  15. }
  16. /* 安装自定义字体 */
  17. @font-face {
  18. font-family: 'font-name';
  19. src: url('url');
  20. }
  21. /* 2. 声明自定义字体图标样式 */
  22. /* unicode */
  23. .iconfont.unicode {
  24. /* 必须先声明自定义的字体名称 */
  25. font-family: iconfont;
  26. font-size: large;
  27. color: green;
  28. text-shadow: #888;
  29. }
  30. /* class 最流行 */
  31. .iconfont.class {
  32. font-size: x-large;
  33. color: violet;
  34. }
  35. .iconfont.class:hover {
  36. font-size: x-large;
  37. color: red;
  38. transition: color 0.5s linear;
  39. }

HTML示例代码

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. <!-- Unicode -->
  9. <link rel="stylesheet" href="css/font-icon.css">
  10. <!-- class -->
  11. <link rel="stylesheet" href="//at.alicdn.com/t/c/font_3778676_ydklqqrp7es.css">
  12. </head>
  13. <body>
  14. <!-- 1. Unicode -->
  15. <div class="iconfont unicode">
  16. <span>&#xe600;</span>
  17. </div>
  18. <hr>
  19. <!-- 2. class -->
  20. <div class="iconfont class">
  21. <span class="icon-shezhi"></span>
  22. <span class="icon-zhuce"></span>
  23. </div>
  24. </body>
  25. </html>
声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议