Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to "fill" background image? [duplicate]

Tags:

css

I'm making a website where I need to have a notable difference between fill and center background images. My template is this:
Center: Uses native resolution to determine size. enter image description here Fill: Fits sides to fill screen without changing aspect ratio. Two sides exactly fit screen, while other two are cut off. enter image description here

I managed to get centered with

.center {
    background-repeat: no-repeat;
    background-size: auto auto;
    background-position: center center;
}

But I can't figure out how I would do fill. Any insight?

like image 257
fin444 Avatar asked Jan 29 '23 05:01

fin444


1 Answers

I believe you want background-size: cover. Other background-size options.

like image 88
Chris Brown Avatar answered Jan 31 '23 07:01

Chris Brown