博主信息
博文 12
粉丝 0
评论 0
访问量 23505
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
字体图标的引用及实例媒体查询
php001
原创
724人浏览过

字体图片的引用

  • 阿里巴巴矢量图库https://www.iconfont.cn 自行下载后引用html页面中
    • 第一步:将事先创建好的css文件使用link标签在html中引用
      1. <link rel="stylesheet" href="css/style.css">
    • 第二步:打开下载好的字体图标文件,找到里面的demo_index.html文件在浏览器中打开,选择 Font class 方法即可查看相关引入步骤,都是傻瓜式操作不过多介绍。
    • 引用实例代码
      1. <div>
      2. <!-- class里面的类名一定要注意看官方字体图标的介绍,不然会写错 -->
      3. <span class="iconfont icon-wode mine"></span>
      4. </div>
  • 自定义样式实例代码:

    1. /* 1. 引入官方的字体图标库 */
    2. @import url(../font_ico/iconfont.css);
    3. /* 自定义图标样式 */
    4. .mine{
    5. font-size: 60px;
    6. background-color: blue;
    7. }
  • 效果图:

媒体查询@media

  • 使用到的属性:max-width min-width
  • max-width:设置一个最大宽度
  • min-width:设置一个最小宽度
    • 实例代码分析:
      1. /* 当屏幕分辨率在480px与1199px之间时,给html设置固定大小字号为14px */
      2. @media (max-width:1199px) and (min-width:480px){
      3. html{
      4. font-size: 14px;
      5. }
      6. }
  • 实例效果图:

    代码分享(全):

    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. <!-- <link rel="stylesheet" href="font_ico\iconfont.css"> -->
    8. <link rel="stylesheet" href="css/style.css">
    9. <title>媒体查询</title>
    10. </head>
    11. <body>
    12. <div class="box">
    13. <div class="one"></div>
    14. <div class="two"></div>
    15. <div class="three"></div>
    16. </div>
    17. <style>
    18. /* 设置根目录的字号大小 */
    19. html {
    20. font-size: 14px;
    21. }
    22. /* 设置box盒子为flex布局 */
    23. .box{
    24. display: flex;
    25. }
    26. /* 给三个one two three盒子设置默认样式 */
    27. .one{
    28. width: 10rem;
    29. height: 5rem;
    30. margin: auto;
    31. background-color: blue;
    32. }
    33. .two{
    34. width: 10rem;
    35. height: 5rem;
    36. margin: auto;
    37. background-color: aqua;
    38. }
    39. .three{
    40. width: 10rem;
    41. height: 5rem;
    42. margin: auto;
    43. background-color: lightgreen;
    44. }
    45. /* 媒体查询@media screen {} */
    46. /* 当屏幕分辨率大于或等于1200px时,给html设置固定大小字号 */
    47. @media (min-width:1200px) {
    48. html{
    49. font-size: 16px;
    50. }
    51. }
    52. /* 当屏幕分辨率在480px与1199px之间时,给html设置固定大小字号 */
    53. @media (max-width:1199px) and (min-width:480px){
    54. html{
    55. font-size: 14px;
    56. }
    57. }
    58. /* 限定最大宽度为480px,如若出现小于480px时 html将固定一个字号大小,不会在变化 */
    59. @media (max-width:480px){
    60. html{
    61. font-size: 13px;
    62. }
    63. }
    64. </style>
    65. </body>
    66. </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+教程免费学