Blogger Information
Blog 25
fans 0
comment 0
visits 10613
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
字体图标和媒体查询实例
PHui
Original
668 people have browsed it

1. 字体运用

html

  1. <!-- Unicode -->
  2. <link rel="stylesheet" href="css/font-icon.css" />
  3. <!-- class -->
  4. <link
  5. rel="stylesheet" href="//at.alicdn.com/t/c/font_3730474_ld9vzyq9bp.css"
  6. <!-- 1. unicode -->
  7. <div class="iconfont unicode">
  8. <span>&#xe640;</span>
  9. </div>
  10. <!-- 2. class -->
  11. <div class="iconfont class">
  12. <span class="icon-icon-test"></span>
  13. </div>

css

  1. /* unicode安装自定义图标字体 */
  2. @font-face {
  3. font-family: 'iconfont'; /* Project id 3730474 */
  4. src: url('//at.alicdn.com/t/c/font_3730474_ld9vzyq9bp.woff2?t=1666775664196') format('woff2'),
  5. url('//at.alicdn.com/t/c/font_3730474_ld9vzyq9bp.woff?t=1666775664196') format('woff'),
  6. url('//at.alicdn.com/t/c/font_3730474_ld9vzyq9bp.ttf?t=1666775664196') format('truetype');
  7. }

2. 媒体查询

css

  1. /* 当视口宽度小于1050px时,导航标签向右不显示 */
  2. @media (max-width: 1050px) {
  3. .Head .HeadNav {
  4. display: none;
  5. }
  6. .Head .HeadRight {
  7. display: none;
  8. }

3. 实例运用

html

  1. <div class="Head">
  2. <div class="logo">
  3. <img
  4. src="https://mbdp01.bdstatic.com/static/landing-pc/img/logo_top.79fdb8c2.png"
  5. />
  6. </div>
  7. <!-- 导航 -->
  8. <div class="HeadNav">
  9. <nav>
  10. <span class="theam">HTMLl</span>
  11. <span class="theam">CSS</span>
  12. <span class="theam">JavaScript</span>
  13. </nav>
  14. </div>
  15. <div class="HeadRight">
  16. <!-- 搜索 -->
  17. <div class="search">
  18. <input
  19. type="text"
  20. value="输入关键词搜索"
  21. name="text1"
  22. class="text1"
  23. id="key_words"
  24. onblur="if(this.value=='') this.value='输入关键词搜索';"
  25. onfocus="if(this.value=='输入关键词搜索') this.value='';"
  26. />
  27. <button>
  28. <div class="iconfont">
  29. <span class="icon-icon-test"></span>
  30. </div>
  31. </button>
  32. </div>
  33. <div class="iconfont class">
  34. <span class="icon-icon-test1"></span>
  35. </div>
  36. <div class="iconfont class">
  37. <span class="icon-icon-test2"></span>
  38. </div>
  39. </div>
  40. </div>
  41. <!-- 客服 -->
  42. <div class="Request">
  43. <div class="iconfont class">
  44. <span class="icon-icon-test3"></span>
  45. </div>
  46. </div>

css

  1. html {
  2. font-size: 10px;
  3. height: 200rem;
  4. }
  5. .Head {
  6. background-color: lightblue;
  7. width: 100vw;
  8. /* 头部固定视口顶部 */
  9. position: fixed;
  10. top: 0;
  11. left: 0;
  12. }
  13. .Head .logo {
  14. display: inline-block;
  15. width: 20rem;
  16. margin-left: 1rem;
  17. }
  18. .Head .logo img {
  19. width: 12rem;
  20. }
  21. .Head .HeadNav {
  22. width: 45rem;
  23. display: inline-block;
  24. }
  25. .Head .HeadNav .theam {
  26. margin: 2rem;
  27. font-size: 3.5rem;
  28. font-family: "Franklin Gothic Medium", "Arial Narrow", Arial, sans-serif;
  29. }
  30. /* 划过时显示颜色和小手 */
  31. .Head .HeadNav .theam:hover {
  32. background-color: coral;
  33. cursor: pointer;
  34. }
  35. .Head .HeadRight {
  36. float: right;
  37. display: inline-block;
  38. width: 38rem;
  39. }
  40. .Head .search {
  41. margin: 1.1rem;
  42. display: inline-block;
  43. }
  44. .Head .search button:hover {
  45. cursor: pointer;
  46. }
  47. .Head .iconfont.class {
  48. display: inline-block;
  49. margin: 1rem;
  50. font-size: x-large;
  51. }
  52. .Head .iconfont.class:hover {
  53. cursor: pointer;
  54. }
  55. /* 客服按钮固定视口右下角 */
  56. .Request {
  57. position: fixed;
  58. right: 0;
  59. bottom: 35%;
  60. }
  61. .Request .iconfont.class {
  62. font-size: xxx-large;
  63. }
  64. .Request .iconfont.class:hover {
  65. cursor: pointer;
  66. }
  67. /* 当视口宽度小于1050px时,导航标签向右不显示 */
  68. @media (max-width: 1050px) {
  69. .Head .HeadNav {
  70. display: none;
  71. }
  72. .Head .HeadRight {
  73. display: none;
  74. }
  75. }

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