11_元素间特性转换.html 971 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Document</title>
  7. <style>
  8. span {
  9. /* block 将元素转换为块元素 */
  10. display: block;
  11. width: 100px;
  12. height: 100px;
  13. background-color: red;
  14. margin: 10px;
  15. }
  16. div {
  17. /* inline 将元素转换为行内元素 */
  18. display: inline;
  19. width: 100px;
  20. height: 100px;
  21. background-color: red;
  22. margin: 10px;
  23. }
  24. i {
  25. display: inline-block;
  26. width: 100px;
  27. height: 100px;
  28. background-color: red;
  29. margin: 10px;
  30. }
  31. </style>
  32. </head>
  33. <body>
  34. <span>你好</span>
  35. <span>世界</span>
  36. <div>hello</div>
  37. <div>world</div>
  38. <i>你好</i>
  39. <i>世界</i>
  40. </body>
  41. </html>