Blogger Information
Blog 16
fans 0
comment 1
visits 5805
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
字体图标与媒体查询(移动优先)
P粉890456325
Original
214 people have browsed it

  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>Document</title>
  8. <link rel="stylesheet" href="css/iconfont.css">
  9. <!-- <link rel="stylesheet" href="//at.alicdn.com/t/c/font_3890717_gk6v9gga9wp.css">
  10. <style>
  11. .iconfont{
  12. font-size: 3em;
  13. color: red;
  14. }
  15. </style> -->
  16. <link rel="stylesheet" href="css/iconfontcss.css">
  17. <style>
  18. .container{
  19. border: 1px solid #000;
  20. background-color: lightcyan;
  21. min-height: 180px;
  22. }
  23. .container.horizontal{
  24. display: flex;
  25. }
  26. .box{
  27. width: 100px;
  28. height: 100px;
  29. margin: 20px;
  30. }
  31. .box.box1{
  32. background-color: violet;
  33. }
  34. .box.box2{
  35. background-color: lightgreen;
  36. }
  37. .box.box3{
  38. background-color: coral;
  39. }
  40. </style>
  41. </head>
  42. <body>
  43. <!-- 1.水平 -->
  44. <div class="container horizontal">
  45. <div class="box box1">1</div>
  46. <div class="box box2">2</div>
  47. </div>
  48. <hr>
  49. <!-- 2.垂直 -->
  50. <div class="container">
  51. <div class="box box1">1</div>
  52. <div class="box box2">2</div>
  53. <div class="box box3" style="margin-top: 50px;">3</div>
  54. </div>
  55. <!-- 3.包含 父子 -->
  56. <hr />
  57. <div class="container">
  58. <div class="box box3 align">3</div>
  59. </div>
  60. <style>
  61. .box.box3.align{
  62. margin: initial;
  63. margin-left: auto;
  64. margin-right: auto;
  65. }
  66. /*
  67. css布局规则
  68. 1. 所有元素,必须在一个"宽度受限,而高度不受限"空间进行布局
  69. 2. 不可能在一个宽度和高度,均不受限制的空间进行布局,必须限制一个方向
  70. 3. 人类查看页面, 习惯从上到下,从左到右,默认宽度不变,而高度随内容自动的伸展
  71. 总结: 宽度受限, 高度伸展
  72. */
  73. </style>
  74. <!-- 1. Unicode -->
  75. <!-- <div style="font-family: iconfont"> -->
  76. <!-- <div class="iconfont unicode"> -->
  77. <div class="my-font">
  78. <span>&#xe697;</span>
  79. </div>
  80. <hr />
  81. <!-- 2class-font -->
  82. <!-- 引用成功后,会有一个class可用, .iconfont -->
  83. <div class="iconfont">
  84. <span class="icon-shezhi active"></span>
  85. </div>
  86. <button class="btn small">Btn1</button>
  87. <button class="btn middle">Btn2</button>
  88. <button class="btn large">Btn3</button>
  89. <style>
  90. /* rem */
  91. html {
  92. /* 1rem = 16px */
  93. /* font-size: 1rem; */
  94. /* 1rem = 10px */
  95. /* font-size: 10px; */
  96. /* 10px = ? rem */
  97. /* 10/16 = 0.625rem */
  98. font-size: 0.625rem;
  99. }
  100. .btn {
  101. background-color: seagreen;
  102. color: white;
  103. border: none;
  104. outline: none;
  105. }
  106. .btn:hover {
  107. cursor: pointer;
  108. opacity: 0.8;
  109. transition: 0.3s;
  110. }
  111. /* 小按钮 */
  112. .btn.small {
  113. font-size: 1.2rem;
  114. }
  115. /* 中按钮 */
  116. .btn.middle {
  117. font-size: 1.6rem;
  118. }
  119. /* 大按钮 */
  120. .btn.large {
  121. font-size: 1.8rem;
  122. }
  123. /* 设置几个断点 */
  124. /* 1. 当宽度 < 375px时, 字号 12px */
  125. @media (max-width: 375px) {
  126. html {
  127. font-size: 12px;
  128. }
  129. }
  130. /* 375px - 600px */
  131. @media (min-width: 375px) and (max-width: 600px) {
  132. html {
  133. font-size: 14px;
  134. }
  135. }
  136. @media (min-width: 600px) {
  137. html {
  138. font-size: 16px;
  139. }
  140. }
  141. </style>
  142. </body>
  143. </html>

css文件

  1. @import url('//at.alicdn.com/t/c/font_3890717_gk6v9gga9wp.css');
  2. .active {
  3. font-size: 3em;
  4. color: seagreen;
  5. }
  6. .active:hover {
  7. font-size: 4em;
  8. color: lightgreen;
  9. cursor: pointer;
  10. transition: 0.5s;
  11. }

css文件

  1. /* CDN 服务仅供平台体验和调试使用,平台不承诺服务的稳定性,企业客户需下载字体包自行发布使用并做好备份。 */
  2. @font-face {
  3. font-family: 'iconfont'; /* Project id 3890717 */
  4. src: url('//at.alicdn.com/t/c/font_3890717_gk6v9gga9wp.woff2?t=1676094132575') format('woff2'),
  5. url('//at.alicdn.com/t/c/font_3890717_gk6v9gga9wp.woff?t=1676094132575') format('woff'),
  6. url('//at.alicdn.com/t/c/font_3890717_gk6v9gga9wp.ttf?t=1676094132575') format('truetype');
  7. }
  8. /*
  9. 1. iconfont: 自定义字体,字体图标
  10. 2. 行内font-family: iconfont
  11. */
  12. /* 1. class叠加 */
  13. .iconfont.unicode {
  14. font-family: iconfont;
  15. font-size: 3em;
  16. color: red;
  17. }
  18. /* 2. 语义化新名称 */
  19. .my-font {
  20. font-family: iconfont;
  21. font-size: 3em;
  22. color: blue;
  23. }
Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post