博主信息
博文 50
粉丝 0
评论 0
访问量 47987
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
字体图标和媒体查询实例演示
手机用户1580651468
原创
591人浏览过

字体图标和媒体查询实例演示

一. 实例演示字体的图标的使用,重点在class方式

一).字体图标是一些网页常见的小图标

二).字体图标的引入(引入到我们html 页面中

1.第一种unicode的方式

1).html代码
  1. <div class="iconfont unicode">
  2. <span>&#xe8b8;</span>
  3. </div>
2).css的代码
  1. @font-face {
  2. font-family: "iconfont"; /* Project id 3734663 */
  3. src: url("//at.alicdn.com/t/c/font_3734663_ixj9olzrj1o.woff2?t=1666923498703")
  4. format("woff2"),
  5. url("//at.alicdn.com/t/c/font_3734663_ixj9olzrj1o.woff?t=1666923498703")
  6. format("woff"),
  7. url("//at.alicdn.com/t/c/font_3734663_ixj9olzrj1o.ttf?t=1666923498703")
  8. format("truetype");
  9. }
  10. /* 安装自定义字体 */
  11. @font-face {
  12. /* 字体名称 */
  13. font-family: font-name’;
  14. src: url(‘url’);
  15. }
  16. /* 2,声明自定义字体图标样式 */
  17. .iconfont.unicode {
  18. font-family: iconfont;
  19. font-size: x-large;
  20. color: green;
  21. text-shadow: 1px 1px 1px #888;
  22. }

2.第二种class的方式

1).html代码
  1. <div class="iconfont class">
  2. <span class="icon-shezhi"></span>
  3. <span class="icon-zhuce"></span>
  4. </div>
2).css代码
  1. .iconfont.unicode {
  2. font-family: iconfont;
  3. font-size: x-large;
  4. color: green;
  5. text-shadow: 1px 1px 1px #888;
  6. }
  7. /* 二 class类声明的形式 */
  8. .iconfont.class {
  9. /* font-family: iconfont; */
  10. font-size: x-large;
  11. color: violet;
  12. }
  13. .iconfont.class:hover {
  14. color: red;
  15. cursor: pointer;
  16. transition: color 0.5s linear;
  17. }

3.两种方式运行的效果图:

二. 实例演示媒体查询原理,媒体查询的顺序

一)代码如下:

  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. <!-- 媒体:屏幕,手机,打印机 -->
  11. <!-- 查询:查询媒体宽度宽度来确定元素的展示方式 -->
  12. <!-- 布局的前提:
  13. 1布局不能再一个无限空间进行,宽,高必须限定一个
  14. 2.默认限定宽度,而高度随内容不断增长 -->
  15. <button class="btn small">按钮1</button>
  16. <button class="btn middle">按钮2</button>
  17. <button class="btn large">按钮3</button>
  18. <style>
  19. html {
  20. font-size: 10px;
  21. }
  22. .btn {
  23. background-color: seagreen;
  24. color: white;
  25. border: none;
  26. outline: none;
  27. }
  28. .btn:hover {
  29. cursor: pointer;
  30. opacity: 0.8;
  31. transition: 0.3s;
  32. padding: 0.4rem 0.8rem;
  33. }
  34. .btn.small {
  35. font-size: 1.2rem;
  36. }
  37. .btn.middle {
  38. font-size: 1.6rem;
  39. }
  40. .btn.large {
  41. font-size: 2rem;
  42. }
  43. /* 媒体查询*/
  44. /* 375px,1rem = 12px */
  45. @media (max-width: 374px) {
  46. html {
  47. font-size: 12px;
  48. }
  49. }
  50. @media (min-width: 375px) and(max-width:449) {
  51. html {
  52. font-size: 14px;
  53. }
  54. }
  55. @media (min-width: 450) {
  56. html {
  57. font-size: 16px;
  58. }
  59. }
  60. </style>
  61. </body>
  62. </html>

二)运行的效果图:

三)媒体查询的顺序是

媒体查询的宽度顺序是:
手机端:从小到大
电脑端:从大到小

批改老师:PHPzPHPz

批改状态:合格

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

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

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