Blogger Information
Blog 28
fans 0
comment 1
visits 13318
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
#css之魔盒及媒体查询
centos
Original
485 people have browsed it

css之魔盒及媒体查询


  1. 写在前言
    / 重置方法 /
    1. .box {
    2. margin: 0;
    3. padding: 0;
    4. box-sizing: border-box;
    5. }
    / 写在前言:像素单位 px em=16px rem=font-size vh/vw=均等分 /
    / 媒体: 屏幕, 打印机 /
    / 查询: 查询当前屏幕宽度变化 /
    / btn增加样式 /
  2. 代码如下:含注释

    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. <style>
    9. html {
    10. font-size: 10px;
    11. }
    12. /* 重置方法 */
    13. /* .box {
    14. margin: 0;
    15. padding: 0;
    16. box-sizing: border-box;
    17. } */
    18. /* 写在前言:像素单位 px em=16px rem=font-size vh/vw=均等分 */
    19. /* 媒体: 屏幕, 打印机 */
    20. /* 查询: 查询当前屏幕宽度变化 */
    21. /* btn增加样式 */
    22. .btn {
    23. background-color: gray;
    24. color: white;
    25. border: none;
    26. outline: none;
    27. }
    28. /* 增加btn效果 */
    29. .btn:hover {
    30. /* 鼠标移动至目标时变形状 cursor */
    31. cursor: pointer;
    32. /* 改变透明度opacity */
    33. opacity: 0.4;
    34. /* 动画时间transition */
    35. transition: 0.4s;
    36. }
    37. .btn.small {
    38. /* 改变大小 */
    39. font-size: 1.2rem;
    40. /* 改变边距 */
    41. padding: 2rem 4rem;
    42. }
    43. .btn.middle {
    44. /* 改变大小 */
    45. font-size: 2rem;
    46. /* 改变边距 */
    47. padding: 2rem 4rem;
    48. }
    49. .btn.large {
    50. /* 改变大小 */
    51. font-size: 2.6rem;
    52. /* 改变边距 */
    53. padding: 2rem 4rem;
    54. }
    55. /* !动态改变rem大小就可以跳转按钮大小
    56. pc优先,从最大的屏幕开始查询 */
    57. @media (max-width: 720px) {
    58. html {
    59. font-size: 20px;
    60. }
    61. }
    62. @media (max-width: 480px) {
    63. html {
    64. font-size: 18px;
    65. }
    66. }
    67. @media (max-width: 360px) {
    68. html {
    69. font-size: 14px;
    70. }
    71. }
    72. @media (min-width: 720px) {
    73. html {
    74. font-size: 20px;
    75. }
    76. }
    77. </style>
    78. </head>
    79. <body>
    80. <div class="box"></div>
    81. <button class="btn small">按钮1</button>
    82. <button class="btn middle">按钮2</button>
    83. <button class="btn large">按钮3</button>
    84. </body>
    85. </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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!