+ 4

How to set background image to fit any screen size?

6th Nov 2018, 4:34 AM
Prince Gupta
Prince Gupta - avatar
7 odpowiedzi
+ 4
background-size: cover;
6th Nov 2018, 5:18 AM
Calviղ
Calviղ - avatar
+ 1
Just a simple example: <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> .responsive { width: 100%; height: auto; } </style> </head> <body> <h2>Responsive Images</h2> <p>If you want the image to scale both up and down on responsiveness, set the CSS width property to 100% and height to auto.</p> <img src="https://via.placeholder.com/150" class="responsive" width="600" height="400"> </body> </html>
6th Nov 2018, 5:19 AM
Mike
0
background-size: cover; this could do it Just like Calviղ said
6th Nov 2018, 6:00 AM
Potato Hacker
Potato Hacker - avatar
0
P1NBALL72 n/a is no thing in css. none is n/a in css and Background-color is Tge Color of the background, Color is the text color.
6th Nov 2018, 10:12 PM
Potato Hacker
Potato Hacker - avatar
- 1
Well there are a couple of ways to do it but you could use bootstrap or css like width:5vw; or width:25%;. It just matters what you think is best for your use.
6th Nov 2018, 4:39 AM
Mike
- 1
Plz show me the code
6th Nov 2018, 4:45 AM
Prince Gupta
Prince Gupta - avatar