Scaling Background Images

PHOTO EMBED

Wed Dec 21 2022 22:39:03 GMT+0000 (Coordinated Universal Time)

Saved by @zaccamp #css

body {
  background-image: url('#');
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
}
content_copyCOPY

In the example above, the first CSS declaration sets the background image (# is a placeholder for an image URL in this example). The second declaration instructs the CSS compiler to not repeat the image (by default, images will repeat). The third declaration centers the image within the element. The final declaration, however, is the focus of the example above. It’s what scales the background image. The image will cover the entire background of the element, all while keeping the image in proportion. If the dimensions of the image exceed the dimensions of the container then only a portion of the image will display.

https://www.codecademy.com/journeys/full-stack-engineer/paths/fscj-22-web-development-foundations/tracks/fscj-22-making-a-website-responsive/modules/wdcp-22-learn-responsive-design-b73c8b37-9b6f-4f4a-aa5c-d0299ca2fdcc/lessons/sizing-elements/exercises/percentages-padding-margin