V
V
Villian_Os2021-07-20 13:05:10
css
Villian_Os, 2021-07-20 13:05:10

How to adapt the background of the site to mobile?

Hello, I installed a static background on the site:

body {
        margin: 150px 0 0;
        background-image: url("https://sun9-11.userapi.com/impg/8f4DsGx6js8z7u1wYrks3qiQaNwJMdRPw1Jd4Q/DThGSmeJy9Q.jpg?size=1920x1080&quality=96&sign=ae91032ec6eda7732b8bb8ccd7c08d3f&type=album");
        background-repeat: no-repeat;
        background-attachment: fixed;
        background:size: cover;
      }


But on mobile, half of the screen is white, the first half is the picture itself, how can I make the picture just stretch?
Here's what it looks like on mobile:
60f69fa98969e796992778.png

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alex, 2021-07-20
@Kozack

try background-size: contain

S
Sergey delphinpro, 2021-07-20
@delphinpro

Focus on the right side of the image:

{
  ...
  background-position: 100% 0;
}

R
Renat, 2021-07-21
@Keylei

@media screen and (max-width:  /*размер экрана*/) {
    body {
        
    }

    header, footer {
        
    }

    a {
        
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question