博客列表 >css引入字体图标及媒体查询

css引入字体图标及媒体查询

P粉854918706
P粉854918706原创
2022年09月15日 12:00:37496浏览

css引入字体图标及媒体查询

1.css引入字体

  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. <title>Document</title>
  8. <link rel="stylesheet" href="font_icon/iconfont.css">
  9. <style>
  10. .myicon{
  11. font-size: 4em;
  12. color:red;
  13. }
  14. .honeicon{
  15. font-size:2em;
  16. color:coral;
  17. background-color: aqua;
  18. }
  19. .honeicon:hover{
  20. color:deeppink;
  21. cursor: pointer;
  22. font-size:3em;
  23. transition-duration: 0.5ms;
  24. }
  25. </style>
  26. </head>
  27. <body>
  28. <div>
  29. <a href="https://www.php.cn/" style="text-decoration: none;"><span class="iconfont icon-camera myicon">照相机</span></a>
  30. </div>
  31. <div>
  32. <span class="iconfont icon-home honeicon">房子</span>
  33. </div>
  34. </body>
  35. </html>

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. <title>Document</title>
  8. <style>
  9. div{
  10. height:50vh;
  11. width:40vw;
  12. border:1px solid lightcoral;
  13. background-color: aqua;
  14. margin:0 auto 10px auto;
  15. }
  16. @media (min-width: 1000px) {
  17. html{
  18. font-size: 16px;
  19. }
  20. .btn1{
  21. margin-left: 10px;
  22. border:none;
  23. outline: none;
  24. background-color: chocolate
  25. }
  26. .btn1:hover{
  27. cursor: pointer;
  28. transition-duration: 3ms;
  29. background-color: blue;
  30. font-size: 20px;
  31. opacity: 0.4;
  32. }
  33. .btn2{
  34. border:none;
  35. outline: none;
  36. background-color: lightgreen;
  37. }
  38. .btn2:hover{
  39. cursor: pointer;
  40. transition-duration: 3ms;
  41. background-color: rgb(240, 29, 14);
  42. font-size: 16px;
  43. opacity: 0.5;
  44. }
  45. .btn3{
  46. margin-top: 10px;
  47. border:none;
  48. outline: none;
  49. background-color: rgb(20, 135, 207);
  50. }
  51. }
  52. @media (max-width: 999px) and (min-width: 800px){
  53. html{
  54. font-size:14px;
  55. }
  56. .btn1{
  57. }
  58. .btn2{
  59. }
  60. .btn3{
  61. }
  62. }
  63. @media (max-width: 799px) and (min-width: 600px){
  64. html{
  65. font-size: 12px;
  66. }
  67. .btn1{
  68. }
  69. .btn2{
  70. }
  71. .btn3{
  72. }
  73. }
  74. @media (max-width: 599px) and (min-width: 400px){
  75. html{
  76. font-size: 10px;
  77. }
  78. .btn1{
  79. }
  80. .btn2{
  81. }
  82. .btn3{
  83. }
  84. }
  85. .small{
  86. font-size: 1.2rem;
  87. }
  88. .middle{
  89. font-size: 1.6rem;
  90. }
  91. .large{
  92. font-size: 2.0rem;
  93. }
  94. .biaodan{
  95. margin-left:100px;
  96. font-size: 1.2rem;
  97. }
  98. .wenben{
  99. background-color: coral;
  100. color:white;
  101. }
  102. input:focus{
  103. background-color: brown;
  104. border:none;
  105. font-size:16px;
  106. outline: none;
  107. }
  108. input::placeholder{
  109. color:white;
  110. }
  111. button{
  112. color:white;
  113. }
  114. </style>
  115. </head>
  116. <body>
  117. <div>
  118. <button class="btn1 small">按钮1</button>
  119. <button class="btn2 middle">按钮2</button>
  120. <button class="btn3 large">按钮3</button>
  121. </div>
  122. <div>
  123. <form action="">
  124. <label for="username" class="biaodan">帐户:</label>
  125. <input type="text" id="username" name="帐户" placeholder="4-8个字符" class="wenben" >
  126. <br>
  127. <label for="psd" class="biaodan">密码:</label>
  128. <input type="password" id="psd" name="密码" placeholder="8-16个字符" class="wenben">
  129. </form>
  130. </div>
  131. </body>
  132. </html>

声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议