03-21-media-object-with-formatting-context.html 950 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Media Object, utilizing the formatting context</title>
  6. <style type="text/css" media="screen">
  7. .media-block {
  8. background-color: gray;
  9. border: solid 1px black;
  10. }
  11. .media-fig {
  12. float: left;
  13. margin-right: 5%;
  14. }
  15. /**
  16. * 1. The overflow rule here creates a new formatting context,
  17. * causing both the container and the .media-body section
  18. * to contain their floats, and causes the .media-body element
  19. * to shift its starting edge so that it sits to the right of the
  20. * floated figure.
  21. */
  22. .media-body, .media-block {
  23. overflow: auto; /* 1 */
  24. }
  25. </style>
  26. </head>
  27. <body>
  28. <div class="media-block">
  29. <img class="media-fig" src="img/pic.png" alt="The pic" />
  30. <div class="media-body">
  31. <h3>Title of this</h3>
  32. <p>Brief description of this</p>
  33. </div>
  34. </div>
  35. </body>
  36. </html>