Skip to content

Commit 22a7ada

Browse files
author
jessicarush
committed
Add: expand descriptions
1 parent f48ef98 commit 22a7ada

File tree

2 files changed

+45
-8
lines changed

2 files changed

+45
-8
lines changed

css_object-fit/base.css

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,15 @@ html {
2323
font-family: var(--main-font);
2424
font-size: 16px;
2525
font-weight: 400;
26+
line-height: 1.7em;
2627
}
2728

29+
code {
30+
line-height: 1.5em;
31+
background: lightcyan;
32+
}
33+
34+
2835
/* TYPOGRAPHY ------------------------------------------------------------- */
2936

3037
.primary-heading {
@@ -39,27 +46,38 @@ html {
3946

4047
/* LAYOUT ----------------------------------------------------------------- */
4148

49+
.centered-container {
50+
max-width: 920px;
51+
margin: 0 auto;
52+
}
53+
54+
4255
/* COMPONENTS ------------------------------------------------------------- */
4356

57+
/* COSMETIC --------------------------------------------------------------- */
58+
4459
.image {
4560
background: rgba(50,50,50,.1);
4661
width: 300px;
4762
height: 300px;
4863
}
64+
4965
.image-contain {
5066
object-fit: contain;
5167
object-position: center;
5268
}
69+
5370
.image-cover {
5471
object-fit: cover;
5572
object-position: right top;
5673
}
5774

75+
.image-fill {
76+
object-fit: fill;
77+
object-position: right top;
78+
}
5879

5980

60-
61-
/* COSMETIC --------------------------------------------------------------- */
62-
6381
/* UTILITY ---------------------------------------------------------------- */
6482

6583
/* STATE ------------------------------------------------------------------ */

css_object-fit/index.html

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,42 @@
33

44
<head>
55
<meta charset="utf-8">
6-
<title>CSS Fit Image</title>
6+
<title>CSS Object Fit</title>
77
<link href="base.css" rel="stylesheet">
88
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800" rel="stylesheet">
99
</head>
1010

1111
<body>
1212

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>
1515
<nav></nav>
1616
</header>
1717

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 &lt;img&gt; or &lt;video&gt;, 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>
1921

2022
<img class="image image-contain" src="plant.jpg">
2123
<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>
2342

2443
</main>
2544

0 commit comments

Comments
 (0)