博客列表 >浮动元素的高度塌陷与解决方案 overflow

浮动元素的高度塌陷与解决方案 overflow

霏梦
霏梦原创
2020年06月19日 19:03:59522浏览

- 作者:霏梦

  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>浮动元素的高度塌陷与解决方案</title>
  7. <style>
  8. .container {
  9. border: 3px solid red;
  10. }
  11. .item {
  12. width: 150px;
  13. height: 150px;
  14. float: left;
  15. }
  16. .item:first-of-type {
  17. background-color: lightgreen;
  18. }
  19. .item:nth-last-of-type(2) {
  20. background-color: lightsalmon;
  21. }
  22. .item:last-of-type {
  23. background-color: magenta;
  24. }
  25. .container {
  26. overflow: auto;
  27. overflow: hidden;
  28. }
  29. </style>
  30. </head>
  31. <body>
  32. <div class="container">
  33. <div class="item"></div>
  34. <div class="item"></div>
  35. <div class="item"></div>
  36. </div>
  37. </body>
  38. </html>
声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议