06-05-position-absolute-overlay-sizing.html 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Absolute positioning from opposing offset points</title>
  6. <style>
  7. body {
  8. margin: 0;
  9. font-family: Avenir, Franklin Gothic, sans-serif;
  10. }
  11. .photo-header {
  12. position: relative;
  13. }
  14. .photo-header img {
  15. max-width: 100%;
  16. display: block;
  17. }
  18. .photo-header h1 {
  19. font-size: 3em;
  20. margin: 0;
  21. }
  22. .photo-header p {
  23. font-size: 1.125em;
  24. margin: 0;
  25. color: #444;
  26. }
  27. .photo-header-plate {
  28. position: absolute;
  29. right: 4em;
  30. bottom: 4em;
  31. left: 4em;
  32. background-color: #fff;
  33. background-color: rgba(255,255,255,0.7);
  34. padding: 2em;
  35. }
  36. </style>
  37. </head>
  38. <body>
  39. <header class="photo-header">
  40. <img src="images/big_spaceship.jpg" alt="An artist’s mockup of the ”Dragon” spaceship">
  41. <div class="photo-header-plate">
  42. <h1>SpaceX unveil the Crew Dragon</h1>
  43. <p>Photo from SpaceX on <a href="https://www.flickr.com/photos/spacexphotos/16787988882/">Flickr</a></p>
  44. </div>
  45. </header>
  46. </body>
  47. </html>