float_excluded_by_flow_root.rml 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <rml>
  2. <head>
  3. <title>Floats excluded by new block formatting context</title>
  4. <link type="text/rcss" href="../style.rcss"/>
  5. <link rel="help (CSS2)" href="https://drafts.csswg.org/css2/#floats" />
  6. <link rel="help (flow-root)" href="https://www.w3.org/TR/css-display-3/#valdef-display-flow-root" />
  7. <link rel="source" href="https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context#exclude_external_floats" />
  8. <meta name="Description" content="The bottom block box should be placed next to its float (not overlap it), as it establishes a new block formatting context that prevent it from being affected by external floats." />
  9. <style>
  10. body {
  11. padding: 10px;
  12. border: 12px #ddd;
  13. border-left: 25px;
  14. width: 500px; /* outer width 557px */
  15. }
  16. section {
  17. display: block;
  18. min-height: 150px;
  19. }
  20. p {
  21. border: 2px #fff;
  22. /*white-space: nowrap;*/
  23. /*text-align: right;*/
  24. }
  25. .box {
  26. background-color: #e0cef7;
  27. border: 5px #663399;
  28. }
  29. .box.flow-root {
  30. display: flow-root;
  31. background-color: #f0f8ff;
  32. border-color: #4682b4;
  33. }
  34. .float {
  35. float: left;
  36. margin-right: 25px;
  37. width: 200px;
  38. height: 100px;
  39. background-color: #fffa;
  40. border: 1px black;
  41. padding: 10px;
  42. position: relative;
  43. }
  44. </style>
  45. </head>
  46. <body>
  47. <section>
  48. <div class="float">Try to resize this outer float<handle size_target="#parent"/></div>
  49. <div class="box"><p id="p">Normal text</p></div>
  50. </section>
  51. <section>
  52. <div class="float">Try to resize this outer float<handle size_target="#parent"/></div>
  53. <div class="box flow-root"><p><code>display: flow-root</code></p></div>
  54. </section>
  55. <handle size_target="#document"/>
  56. </body>
  57. </rml>