Jump to content

Making sure a background image looks good on mobile

Recommended Posts

Hello! My client wants a textured image for his site background. It was zooming in onit in a way I didn't like so I added this code:


.your-class {
    background-size: cover; /* Ensures the background image covers the entire area */
    background-position: center center; /* Centers the image, reducing the chance of awkward cropping */
}

@media only screen and (max-width: 768px) {
    .your-class {
        background-size: contain; /* Adjusts the background size to fit on smaller screens */
        background-position: top center; /* Alters the position to handle cropping differently */
    }

 

This worked on every page except the home page. I thought maybe it was bc it was the homepage, but switching which page was home didn't work. I thought maybe if I rebuilt it...worked for a second, but by the time I was done, it stopped working.

 

Any ideas? Thanks!!

Link to comment
  • Replies 2
  • Views 218
  • Created
  • Last Reply

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.