登录  /  注册
博主信息
博文 77
粉丝 0
评论 0
访问量 76212
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
字体图标的引入与显示,实例媒体查询
Jet的博客
原创
744人浏览过

一、字体图标的引入

1.1 unicode和fontclass引入

HTML文件

  1. <link rel="stylesheet" href="css/css.css">
  2. <link rel="stylesheet" href="css/css1.css">
  3. <title>引入字体iconfont</title>
  4. </head>
  5. <!-- 1、unicode引入:css文件引入Unicode代码 -->
  6. <div class="my-font">
  7. <span>&#xe6a2;</span>
  8. <span>&#xe68d;</span>
  9. </div>
  10. <!-- 2、fontcss引入:css文件引入css链接 -->
  11. <div class="iconfont">
  12. <span class="icon-yonghutianchong active"></span>
  13. </div>
  14. <div class="iconfont">
  15. <span class="icon-shezhitianchong active"></span>
  16. </div>

css.css文件

  1. /*1、unicode引入*/
  2. @font-face {
  3. font-family: 'user_iconfont'; /* Project id 3884767 */
  4. src: url('//at.alicdn.com/t/c/font_3884767_x7v7y9uy9zm.woff2?t=1675783006602') format('woff2'),
  5. url('//at.alicdn.com/t/c/font_3884767_x7v7y9uy9zm.woff?t=1675783006602') format('woff'),
  6. url('//at.alicdn.com/t/c/font_3884767_x7v7y9uy9zm.ttf?t=1675783006602') format('truetype');
  7. }
  8. .my-font {
  9. font-family: user_iconfont; font-size: 3em; color: blue;
  10. }

css1.css文件

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




1.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. <link rel="stylesheet" href="css/iconfont.css">
  8. <title>下载本地引入字体iconfont</title>
  9. </head>
  10. <body>
  11. <!--3、下载本地引入-->
  12. <div class="iconfont">
  13. <span>&#xe6a2;</span>
  14. </div>
  15. </body>
  16. </html>
  1. @font-face {
  2. font-family: "iconfont"; /* Project id 3884767 */
  3. src: url('../font/iconfont.woff2?t=1675818606114') format('woff2'),
  4. url('../font/iiconfont.woff?t=1675818606114') format('woff'),
  5. url('../font/iiconfont.ttf?t=1675818606114') format('truetype');
  6. }
  7. .iconfont {
  8. font-family: "iconfont" !important;
  9. font-size: 16px;
  10. font-style: normal;
  11. -webkit-font-smoothing: antialiased;
  12. -moz-osx-font-smoothing: grayscale;
  13. color:brown;
  14. }
  15. .icon-shezhitianchong:before {
  16. content: "\e68d";
  17. }
  18. .icon-yonghutianchong:before {
  19. content: "\e6a2";
  20. }



二、实例媒体查询

  1. <body>
  2. <button class="btn small">Btn1</button>
  3. <button class="btn middle">Btn2</button>
  4. <button class="btn large">Btn3</button>
  5. <style type="text/css">
  6. html { font-size: 0.625rem; }
  7. .btn {
  8. background-color: seagreen;
  9. color: white;
  10. border: none;
  11. outline: none;
  12. }
  13. .btn:hover { cursor: pointer; opacity: 0.8; transition: 0.3s; }
  14. /* 小按钮 */
  15. .btn.small { font-size: 1.2rem; }
  16. /* 中按钮 */
  17. .btn.middle { font-size: 1.4rem; }
  18. /* 大按钮 */
  19. .btn.large { font-size: 1.6rem; }
  20. /* 1. 当宽度 < 375px时, 字号 12px */
  21. @media (max-width: 375px) {
  22. html { font-size: 12px; }
  23. }
  24. /* 375px - 600px */
  25. @media (min-width: 375px) and (max-width: 600px) {
  26. html { font-size: 14px; }
  27. }
  28. @media (min-width: 600px) {
  29. html { font-size: 16px; }
  30. }
  31. </style>
  32. </body>




总结:

1、字体图标等引入可以去 https://www.iconfont.cn/,进行,方便;

2、媒体查询注意是通过:@media,获取屏幕max-width或者min-width属性进行css调整。

操作符:and not only

书写顺序:手机端从小到大,PC端从大到小

批改老师:PHPzPHPz

批改状态:合格

老师批语:
本博文版权归博主所有,转载请注明地址!如有侵权、违法,请联系admin@php.cn举报处理!
全部评论 文明上网理性发言,请遵守新闻评论服务协议
0条评论
作者最新博文
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号

  • 登录PHP中文网,和优秀的人一起学习!
    全站2000+教程免费学