博客列表 >字体图标及媒体查询

字体图标及媒体查询

生活需要加油
生活需要加油原创
2023年02月09日 11:03:40511浏览

字体图标及媒体查询

1. 字体图标的引入与显示

font-icon-unicode.css

  1. @font-face {
  2. font-family: "iconfont"; /* Project id 3886259 */
  3. src: url("//at.alicdn.com/t/c/font_3886259_rduojctudo.woff2?t=1675848609007")
  4. format("woff2"),
  5. url("//at.alicdn.com/t/c/font_3886259_rduojctudo.woff?t=1675848609007")
  6. format("woff"),
  7. url("//at.alicdn.com/t/c/font_3886259_rduojctudo.ttf?t=1675848609007")
  8. format("truetype");
  9. }
  10. .dhw-font {
  11. font-family: iconfont;
  12. font-size: 5em;
  13. color: blue;
  14. }

font-icon-class.css

  1. @import url(//at.alicdn.com/t/c/font_3886259_rduojctudo.css);
  2. .active {
  3. font-size: 5em;
  4. color: cyan;
  5. }
  6. .active:hover {
  7. font-size: 6em;
  8. cursor: pointer;
  9. opacity: 0.2;
  10. transition: 0.6s;
  11. }

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. <link rel="stylesheet" href="css/icon-font-unicode.css" />
  8. <link rel="stylesheet" href="css/font-icon-class.css" />
  9. <title>字体图标</title>
  10. </head>
  11. <body>
  12. <!-- 1.unicode -->
  13. <div class="dhw-font">
  14. <span>&#xe635;</span>
  15. </div>
  16. <hr />
  17. <div class="iconfont">
  18. <span class="icon-shejishi2 active"></span>
  19. </div>
  20. </body>
  21. </html>

网页效果
iconfont

2. 媒体查询(移动优先)

  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  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>媒体查询</title>
  8. </head>
  9. <body>
  10. <button class="btn small">小宝</button>
  11. <button class="btn middle">二宝</button>
  12. <button class="btn large">大宝</button>
  13. <style>
  14. html {
  15. /* 设置1rem=10px */
  16. font-size: 0.625rem;
  17. }
  18. .btn {
  19. background-color: cyan;
  20. color: white;
  21. border: none;
  22. outline: none;
  23. }
  24. .btn:hover {
  25. cursor: pointer;
  26. opacity: 0.2;
  27. transition: 0.3s;
  28. }
  29. .btn.small {
  30. font-size: 1.5rem;
  31. }
  32. .btn.middle {
  33. font-size: 2rem;
  34. }
  35. .btn.large {
  36. font-size: 2.5rem;
  37. }
  38. @media (max-width: 375px) {
  39. html {
  40. font-size: 12px;
  41. }
  42. }
  43. @media (min-width: 375px) and (max-width: 600px) {
  44. html {
  45. font-size: 16px;
  46. }
  47. }
  48. @media (min-width: 600px) {
  49. html {
  50. font-size: 18px;
  51. }
  52. }
  53. </style>
  54. </body>
  55. </html>

网页效果
mediaquery

声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议