diff --git a/curriculum/challenges/english/01-responsive-web-design/responsive-web-design-principles/make-an-image-responsive.english.md b/curriculum/challenges/english/01-responsive-web-design/responsive-web-design-principles/make-an-image-responsive.english.md index 566f27633b..f01803a41d 100644 --- a/curriculum/challenges/english/01-responsive-web-design/responsive-web-design-principles/make-an-image-responsive.english.md +++ b/curriculum/challenges/english/01-responsive-web-design/responsive-web-design-principles/make-an-image-responsive.english.md @@ -8,24 +8,22 @@ forumTopicId: 301140 ## Description
-Making images responsive with CSS is actually very simple. Instead of applying an absolute width to an element: -img { width: 720px; } -You can use: +Making images responsive with CSS is actually very simple. You just need to add these properties to an image: ```css img { max-width: 100%; - display: block; height: auto; } ``` -The max-width property of 100% scales the image to fit the width of its container, but the image won't stretch wider than its original width. Setting the display property to block changes the image from an inline element (its default), to a block element on its own line. The height property of auto keeps the original aspect ratio of the image. +The `max-width` of `100%` will make sure the image is never wider than the container it is in, and the `height` of `auto` will make the image keep its original aspect ratio.
## Instructions
-Add style rules for the img tag to make it responsive to the size of its container. It should display as a block-level element, it should fit the full width of its container without stretching, and it should keep its original aspect ratio. + +Add the style rules to the `responsive-img` class to make it responsive. It should never be wider than its container (in this case, it's the preview window) and it should keep its original aspect ratio. After you have added your code, resize the preview to see how your images behave.
## Tests @@ -33,11 +31,9 @@ Add style rules for the img tag to make it responsive to the size o ```yml tests: - - text: Your img tag should have a max-width set to 100%. - testString: assert(code.match(/max-width:\s*?100%;/g)); - - text: Your img tag should have a display set to block. - testString: assert($('img').css('display') == 'block'); - - text: Your img tag should have a height set to auto. + - text: Your responsive-img class should have a max-width set to 100%. + testString: assert(getComputedStyle($('.responsive-img')[0]).maxWidth === '100%'); + - text: Your responsive-img class should have a height set to auto. testString: assert(code.match(/height:\s*?auto;/g)); ``` @@ -51,9 +47,17 @@ tests: ```html +freeCodeCamp stickers set freeCodeCamp stickers set ``` @@ -68,13 +72,17 @@ tests: ```html +freeCodeCamp stickers set freeCodeCamp stickers set ```