|
3 | 3 |
|
4 | 4 | <head> |
5 | 5 | <meta charset="utf-8"> |
6 | | - <title>CSS Fit Image</title> |
| 6 | + <title>CSS Object Fit</title> |
7 | 7 | <link href="base.css" rel="stylesheet"> |
8 | 8 | <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800" rel="stylesheet"> |
9 | 9 | </head> |
10 | 10 |
|
11 | 11 | <body> |
12 | 12 |
|
13 | | - <header> |
14 | | - <h1 class="primary-heading">CSS Fit Image</h1> |
| 13 | + <header class="centered-container"> |
| 14 | + <h1 class="primary-heading">CSS Object Fit & Position</h1> |
15 | 15 | <nav></nav> |
16 | 16 | </header> |
17 | 17 |
|
18 | | - <main> |
| 18 | + <main class="centered-container"> |
| 19 | + |
| 20 | + <p><code>object-fit</code> sets how the content of a replaced element, such as an <img> or <video>, should be resized to fit its container. You can modify the alignment within the element's box using the <code>object-position</code> property.</p> |
19 | 21 |
|
20 | 22 | <img class="image image-contain" src="plant.jpg"> |
21 | 23 | <img class="image image-cover" src="plant.jpg"> |
22 | | - |
| 24 | + <img class="image image-fill" src="plant.jpg"> |
| 25 | + |
| 26 | + <h2 class="primary-heading">object-fit values</h2> |
| 27 | + <ul> |
| 28 | + <li><code>fill</code> - stretched to fill the element’s content box</li> |
| 29 | + <li><code>contain</code> - scaled to maintain its aspect ratio while fitting within the element’s content box</li> |
| 30 | + <li><code>cover</code> - sized to maintain its aspect ratio while filling the element’s entire content box</li> |
| 31 | + <li><code>none</code> - no resizing</li> |
| 32 | + <li><code>scale-down</code> - sized as if none or contain were specified, whichever would result in a smaller concrete object size</li> |
| 33 | + </ul> |
| 34 | + |
| 35 | + <h2 class="primary-heading">object-position values</h2> |
| 36 | + <ul> |
| 37 | + <li><code>object-position: 50% 50%;</code></li> |
| 38 | + <li><code>object-position: right top;</code></li> |
| 39 | + <li><code>object-position: center;</code></li> |
| 40 | + <li><code>object-position: 250px 125px;</code></li> |
| 41 | + </ul> |
23 | 42 |
|
24 | 43 | </main> |
25 | 44 |
|
|
0 commit comments