ASCII码 ASCII码

class方式引入字体图标,以及自定义样式 ,实例演示媒体查询(PC优先模式)

发布于:2022-07-11 14:49:12  栏目:技术文档

1.实例演示使用class方式引入字体图标,以及自定义样式

  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>引入图标</title>
  8. <link rel="stylesheet" href="style.css">
  9. </head>
  10. <body>
  11. <div>
  12. <span class="iconfont icon-jingdong">京东</span>
  13. </div>
  14. </body>
  15. </html>

style.css样式

  1. /* 1. 引入官方的字体图标库 */
  2. @import 'font_icon/iconfont.css';
  3. /* 2.自定义图标 */
  4. .icon-jingdong {
  5. color: aliceblue;
  6. font-size: 50px;
  7. box-shadow: 2px 2px 2px #888;
  8. border-radius: 5%;
  9. background-color: red;
  10. }

2.实例演示媒体查询(PC优先模式)

  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>实例演示媒体查询</title>
  8. </head>
  9. <body>
  10. <div class="box"></div>
  11. <style>
  12. * {
  13. margin: 0;
  14. padding: 0;
  15. }
  16. .box {
  17. width: 200px;
  18. height: 200px;
  19. background-color: lightgreen;
  20. border-radius: 5%;
  21. box-shadow: 2px 2px 2px #888;
  22. }
  23. div:hover {
  24. cursor: pointer;
  25. opacity: 0.8;
  26. transition: 0.3s;
  27. }
  28. /* PC优先: 先从最大屏的设备进行适配 */
  29. /* 1000, 800 600 450 350 */
  30. @media (min-width: 1000px) {
  31. .box {
  32. background-color: red;
  33. }
  34. }
  35. @media (min-width: 800px) and (max-width: 999px) {
  36. .box {
  37. background-color: orange;
  38. }
  39. }
  40. @media (min-width: 600px) and (max-width: 799px) {
  41. .box {
  42. background-color: yellow;
  43. }
  44. }
  45. @media (min-width: 450px) and (max-width: 599px) {
  46. .box {
  47. background-color: green
  48. }
  49. }
  50. @media (min-width: 350px) and (max-width: 449px) {
  51. .box {
  52. background-color: cyan;
  53. }
  54. }
  55. @media (max-width: 349px) {
  56. .box {
  57. background-color: blue;
  58. }
  59. }
  60. </style>
  61. </body>
  62. </html>
相关推荐
阅读 +