Blogger Information
Blog 94
fans 0
comment 0
visits 92710
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
【CSS】媒体查询 -- 屏幕宽度自适应:@media
可乐随笔
Original
720 people have browsed it

媒体查询

媒体查询的宽度顺序:

  1. 移动端:从小往大小
  2. PC端:反过来,从大向小写
  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. <button class="btn small">按钮1</button>
  11. <button class="btn middle">按钮2</button>
  12. <button class="btn large">按钮3</button>
  13. <style>
  14. /* REM
  15. root === html */
  16. html{
  17. /* 1rem = 10px; */
  18. font-size: 10px;
  19. }
  20. .btn{
  21. background:green;
  22. color: white;
  23. border: none;
  24. outline: none;
  25. }
  26. .btn:hover{
  27. cursor: pointer;
  28. opacity: 0.8;
  29. transition: 0.3;
  30. }
  31. .btn.small{
  32. font-size: 1.2rem;
  33. }
  34. .btn.middle{
  35. font-size: 1.6rem;
  36. }
  37. .btn.large{
  38. font-size: 1.8rem;
  39. }
  40. /* 媒体查询 */
  41. /* 1rem = 10px; , 1rem = 12px */
  42. /* < 375px, 1rem = 12px; */
  43. /* 屏幕小于(最大)375px */
  44. @media (max-with){
  45. html{
  46. font-size: 12px;
  47. }
  48. }
  49. @media (min-width:375px) and (max-width:414px){
  50. html{
  51. font-size: 14px;
  52. }
  53. }
  54. @media (min-with:415px){
  55. html{
  56. font-size: 16px;
  57. }
  58. }
  59. /* 媒体查询的宽度顺序:
  60. 1. 移动端:从小往大小
  61. 2. PC端:反过来,从大向小写
  62. */
  63. </style>
  64. </body>
  65. </html>
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