.container-class { background-image: url("path/to/image.jpg"); background-repeat: no-repeat; background-position: center; width: 400px; height: 400px; border: 2px dashed #333;}
To define a specific size for the image, we should look at the background-size property relative to the aspect ratio of the image:a) For an image that has more width than height, please include the syntax below to make the background image go full width:background-size: 100% auto;
b) For an image that has more height than width, please include the syntax below to make the background image go full height: background-size: auto 100%;
c) Include this syntax to make the background image go full coverage. This is an automatic way to fill the complete container, regardless of the image’s aspect ratio: background-size: cover;
This is the complete list of background-size values: