Blogger Information
Blog 37
fans 0
comment 1
visits 28113
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
css字体图标引入与媒体查询
kong
Original
607 people have browsed it

字体图标

1. 阿里图标

链接 https://www.iconfont.cn/

进入阿里图标,新建一个项目,选择好图标加入项目。
1.2 .iconfont: 自定义字体,字体图标
1.3 .font-family: iconfont
1.4 .使用 @font-face

2. 类名图标 直观通用(个人推荐使用)

  1. 类名图标 直观通用推荐使用

  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. <!-- 引入成功以后会有一个 .iconfont使用 -->
  9. <link rel="stylesheet" href="//at.alicdn.com/t/c/font_3013559_jege94jsqh.css">
  10. </head>
  11. <style>
  12. *{
  13. padding: 0;
  14. margin: 0;
  15. }
  16. .icon i{
  17. font-size: 5rem;
  18. color: red;
  19. font-weight: 700;
  20. }
  21. </style>
  22. <body>
  23. <div class="icon">
  24. <!--必须加入iconfont,后面在写入图标类名-->
  25. <i class="iconfont icon-duanzhen6"></i>
  26. </div>
  27. </body>
  28. </html>

3. Unicode: 兼容性好 (如果乱码就不行了)

  1. Unicode: 兼容性好

  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. <!-- 引入成功以后会有一个 .iconfont使用 -->
  9. <link rel="stylesheet" href="//at.alicdn.com/t/c/font_3013559_jege94jsqh.css">
  10. </head>
  11. <style>
  12. @font-face {
  13. /* 定义字体名称 */
  14. font-family: 'iconfont';
  15. /* 字体文件的位置 */
  16. src: url('//at.alicdn.com/t/c/font_3013559_jege94jsqh.woff2?t=1675127744439') format('woff2'),
  17. url('//at.alicdn.com/t/c/font_3013559_jege94jsqh.woff?t=1675127744439') format('woff'),
  18. url('//at.alicdn.com/t/c/font_3013559_jege94jsqh.ttf?t=1675127744439') format('truetype');
  19. }
  20. *{
  21. padding: 0;
  22. margin: 0;
  23. }
  24. span{
  25. font-family: 'iconfont';
  26. color: red;
  27. font-weight: 700;
  28. font-size: 5em;
  29. }
  30. </style>
  31. <body>
  32. <span>&#xe60e;</span>
  33. </body>
  34. </html>

媒体查询

根据媒体宽度确定展示方式与内容
指令: @media,默认screen(屏幕)
属性:max-width小于,min-width大于
操作符:and,not,only
书写顺序: 1. 移动端优先: 从小到大 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="container">
  11. <h1>媒体查询</h1>
  12. <h2>hello</h2>
  13. </div>
  14. <style>
  15. html{
  16. /* 初始值 */
  17. font-size: .625rem;
  18. }
  19. /* 移动优先 */
  20. @media(max-width: 375px){
  21. html{
  22. /* //使用具体的PX值 */
  23. font-size: 12px;
  24. }
  25. h1{
  26. font-size: 1rem;
  27. color: darkblue;
  28. }
  29. h2{
  30. font-size: 0.8rem;
  31. color: aquamarine;
  32. }
  33. }
  34. /* 区间大于375px并且小于640px */
  35. @media(min-width: 375px)and(max-width:640px){
  36. /* 写入css样式 */
  37. html{
  38. /* //使用具体的PX值 */
  39. font-size: 14px;
  40. }
  41. }
  42. /* min-width: 640px,大于640px */
  43. @media(min-width: 640px){
  44. /* 写入css样式 */
  45. html{
  46. /* //使用具体的PX值 */
  47. font-size: 16px;
  48. }
  49. }
  50. </style>
  51. </body>
  52. </html>

总结:

  1. 字体图标引入选择类名图标方式引入
  2. 媒体查询根据项目需要进行选择是移动优先还是PC优先!哪个优先哪个尺寸写在上面
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!