This CSS enables you to add a background image to any widget area in any theme.
In this case the image has been uploaded to the WordPress Media Library however, you can also upload the image file to your child themes images folder and use this method :
.front-page-2 {
background-image: url('https://wpsites.net/wp-content/uploads/2018/10/hero.jpg');
background-color: #cccccc;
height: 500px;
background-position: center;
background-repeat: no-repeat;
background-size: contain;
}
Assumes your main widget area class is front-page-2
otherwise swap that out to match your widgets container class.
CSS Installation #
Swap out the URL to your background image in the above CCS rule and paste at the end of your child themes functions file. Clear caching.
You can also upload a image to your child themes images folder and use this CSS declaration in replace of the full image link :
background-image: url('images/hero.jpg');
Use the following declaration to make the image cover the entire widget container :
background-size: cover;
To do this, change the value for the background-image from contain to cover.
Was This Tutorial Helpful?