style.html 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Title</title>
  6. <style>
  7. div{
  8. width: 200px; height: 100px;
  9. background-color: aqua;
  10. }
  11. .demo1 {
  12. background-color: red;
  13. }
  14. #demo2 {
  15. /*background-color: black;*/
  16. }
  17. </style>
  18. </head>
  19. <body>
  20. <div class="demo1" style="background-color: green">1</div>
  21. <hr />
  22. <div class="demo1">2
  23. <span class="demo3"></span>
  24. </div>
  25. <hr />
  26. <div id="demo2">
  27. <div id="positiondemo" style="width: 200px; height: 100px; background-color: red"> 我是内元素 </div>
  28. </div>
  29. <input value="我是input" />
  30. </body>
  31. <style>
  32. /*padding margin*/
  33. #positiondemo {
  34. position: absolute;
  35. left: 400px;
  36. right: 200px;
  37. }
  38. /*
  39. px 基于像素单位
  40. em 基于父元素 字体单位 // 1em 当前元素的 父元素 的1个字体 单位 font-size: 20px
  41. rem 基于根元素 字体单位 // 1em 等于 html 元素的 1个字体 单位
  42. vh 视口高度单位 1vh 就是一个视口宽度
  43. vw 视口宽度单位 1vw 就是网页可见高度
  44. */
  45. </style>
  46. </html>