Configuration

Responsive background image size

Responsive background image size

Make a background image fill any screen size with background-size: cover, and use background-position to choose which part stays visible.

Setting a background image for your div is easy.

You can do this like:

background-image: url('<link to image'); background-size:cover;background-attachment: fixed;

However, on mobile, this results in not showing the background image, because no height is set. Setting a fixed height will show the background image in the fixed height you set. Often this is not the best solution. You want the image to be the entire height of the div, and that may vary.

You can simply fix this by adding the following code to your div's class

Overflow:hidden

Now the image will take the size of the div it resides in.

Stuck on something else?

Doctor Joomla is a project of Cloudfaction, a Dutch agency building and maintaining Joomla sites since 1999. The articles are made with the help of AI, so tell us if something does not match your screen. Mail info@cloudfaction.nl if you want someone to look at yours.

Rather have someone look at it

Doctor Joomla is a Cloudfaction project.

A Dutch agency that has been building and running Joomla sites since 1999. If your site needs more than an article can fix, get in touch.