|
| 1 | +<!doctype html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | + <meta charset="utf-8" /> |
| 5 | + |
| 6 | + <title> |
| 7 | + Revisiting: Styling A Movie Cast List Using A Definition List And Flexbox |
| 8 | + </title> |
| 9 | + |
| 10 | + <style type="text/css"> |
| 11 | + |
| 12 | + a { |
| 13 | + color: red ; |
| 14 | + } |
| 15 | + |
| 16 | + dl.cast-list { |
| 17 | + font-family: monospace ; |
| 18 | + font-size: 20px ; |
| 19 | + width: 500px ; |
| 20 | + } |
| 21 | + |
| 22 | + dl.cast-list div { |
| 23 | + /* |
| 24 | + Setup the DT (character), DD (cast), and pseudo-element items as a |
| 25 | + flexible layout. |
| 26 | + */ |
| 27 | + display: flex ; |
| 28 | + margin: 5px 0px 5px 0px ; |
| 29 | + } |
| 30 | + |
| 31 | + dl.cast-list dt { |
| 32 | + /* |
| 33 | + In order to avoid creating nested flexbox containers, we are going to use |
| 34 | + the "display: contents" to "remove" the DT element from visual rendering. |
| 35 | + This will promote the DT text and :after elements to be "siblings" of the |
| 36 | + DD element, allowing a single flexbox container to affect all 3 items. |
| 37 | + */ |
| 38 | + display: contents ; |
| 39 | + /* |
| 40 | + Setup the DT (character) element to shrink, allowing for the dots to fill |
| 41 | + up the free space. |
| 42 | + */ |
| 43 | + flex: 0 1 auto ; |
| 44 | + } |
| 45 | + |
| 46 | + dl.cast-list dt:after { |
| 47 | + border-bottom: 2px dotted #787878 ; |
| 48 | + content: "" ; |
| 49 | + /* |
| 50 | + Setup the :after element to grow, filling up the free space with dots. |
| 51 | + -- |
| 52 | + NOTE: Since we are using "display: contents" on the parent container, |
| 53 | + this pseudo-element is logically rendered as a SIBLING of both the DT |
| 54 | + TEXT (implicit element) and the DD element. |
| 55 | + */ |
| 56 | + flex: 1 1 auto ; |
| 57 | + margin: 0px 12px 5px 12px ; |
| 58 | + } |
| 59 | + |
| 60 | + dl.cast-list dd { |
| 61 | + /* |
| 62 | + Setup the DD (cast) element to shrink, allowing for the dots to fill up |
| 63 | + the free space. |
| 64 | + */ |
| 65 | + flex: 0 1 auto ; |
| 66 | + margin: 0px 0px 0px 0px ; |
| 67 | + } |
| 68 | + |
| 69 | + </style> |
| 70 | +</head> |
| 71 | +<body> |
| 72 | + |
| 73 | + <h1> |
| 74 | + Revisiting: Styling A Movie Cast List Using A Definition List And Flexbox |
| 75 | + </h1> |
| 76 | + |
| 77 | + <h2> |
| 78 | + Using "display: contents" — Thanks To Sime Vidas |
| 79 | + </h2> |
| 80 | + |
| 81 | + <h3> |
| 82 | + <a href="https://www.imdb.com/title/tt0168987/"> |
| 83 | + Better Than Chocolate |
| 84 | + </a> |
| 85 | + </h3> |
| 86 | + |
| 87 | + <dl class="cast-list"> |
| 88 | + <div> |
| 89 | + <dt>Lila</dt> |
| 90 | + <dd>Wendy Crewson</dd> |
| 91 | + </div> |
| 92 | + <div> |
| 93 | + <dt>Maggie</dt> |
| 94 | + <dd>Karyn Dwyer</dd> |
| 95 | + </div> |
| 96 | + <div> |
| 97 | + <dt>Kim</dt> |
| 98 | + <dd>Christina Cox</dd> |
| 99 | + </div> |
| 100 | + <div> |
| 101 | + <dt>Frances</dt> |
| 102 | + <dd>Ann-Marie MacDonald</dd> |
| 103 | + </div> |
| 104 | + <div> |
| 105 | + <dt>Carla</dt> |
| 106 | + <dd>Marya Delver</dd> |
| 107 | + </div> |
| 108 | + </dl> |
| 109 | + |
| 110 | +</body> |
| 111 | +</html> |
0 commit comments