Blogger Information
Blog 20
fans 0
comment 0
visits 8462
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
1024作业(en和rem)
A 管志岗-电商策划
Original
625 people have browsed it

1. em,rem的特点是什么?应用场景是什么?

em: 是继承父级元素或者当前元素

也是随着父级或者当前元素变换大小
根元素设置方式:
使用方式推荐用电脑端

rem: 是根元素,可以自定义

建议手机端使用
html 或者 伪类 :root,都可以自定义
使用方式推荐用电手机端

  1. html{
  2. font-size:32px;
  3. }
  4. :root{
  5. font-size:32px;
  6. }

使用rem+vw做表格

  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. :root {
  10. /* margin: 0; */
  11. /* padding: 0; */
  12. font-size: 100px;
  13. /* 1rem = 100px */
  14. }
  15. </style>
  16. </head>
  17. <body>
  18. <table
  19. border="1"
  20. style="
  21. line-height: 0.3rem;
  22. width: 40vw;
  23. text-align: center;
  24. font-size: 0.16rem;
  25. border-radius: 0.1rem;
  26. border-collapse: collapse;
  27. "
  28. >
  29. <caption>
  30. 商品属性
  31. </caption>
  32. <thead style="background-color: #f40">
  33. <tr>
  34. <th>1</th>
  35. <th>名称</th>
  36. <th>价格</th>
  37. <th>颜色</th>
  38. <th>尺寸</th>
  39. <th>配置</th>
  40. </tr>
  41. </thead>
  42. <!-- 表体必选,浏览器自动生成tbody,一个表格中可以有多个tbody -->
  43. <tbody>
  44. <!-- 先写tr,创建一个新行(单元格的容器)
  45. td单元格储存数据的地方,th有预置样式:加粗居中
  46. 跨行合并:rowspan, row行, span合并
  47. -->
  48. <tr>
  49. <td>1</td>
  50. <td>联想</td>
  51. <td>4500</td>
  52. <td>红色</td>
  53. <td>14</td>
  54. <td>i5</td>
  55. </tr>
  56. <tr>
  57. <td>2</td>
  58. <td>鸿基</td>
  59. <td>4800</td>
  60. <td rowspan="3">黑色</td>
  61. <td>13</td>
  62. <td>i5</td>
  63. </tr>
  64. <tr>
  65. <td>3</td>
  66. <td>戴尔</td>
  67. <td>4900</td>
  68. <!-- <td>黄色</td> -->
  69. <td>15</td>
  70. <td>i7</td>
  71. </tr>
  72. <tr>
  73. <td>4</td>
  74. <td>华硕</td>
  75. <td>6000</td>
  76. <!-- <td>黑色</td> -->
  77. <td>14.8</td>
  78. <td>i7</td>
  79. </tr>
  80. <tr>
  81. <td>5</td>
  82. <td>苹果</td>
  83. <td>8999</td>
  84. <td>白色</td>
  85. <td>14</td>
  86. <td>i7</td>
  87. </tr>
  88. </tbody>
  89. <tfoot>
  90. <tr>
  91. <th>6</th>
  92. <th></th>
  93. <th>29199</th>
  94. <th colspan="3"></th>
  95. <!-- <th>29199</th> -->
  96. <!-- <th>29199</th> -->
  97. </tr>
  98. </tfoot>
  99. </table>
  100. </body>
  101. </html>

效果图width=40vw ==> 40%

效果图

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!