练习题4_垂直水平居中.html 749 B

123456789101112131415161718192021222324252627282930313233343536
  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. .box{
  9. width: 400px;
  10. height: 400px;
  11. border:1px dashed black;
  12. float: left;
  13. margin-left: 50px;
  14. margin-top: 50px;
  15. }
  16. .div1{
  17. width: 100px;
  18. height: 100px;
  19. background-color: red;
  20. }
  21. span{
  22. background-color: red;
  23. color: #fff;
  24. }
  25. </style>
  26. </head>
  27. <body>
  28. <div class="box">
  29. <div class="div1"></div>
  30. </div>
  31. <div class="box">
  32. <span>hello</span>
  33. </div>
  34. </body>
  35. </html>