I have an JPG image with size 1024 x 724. My page size is not fixed. My requirement is: If I resize the page then the background image should also resize and fit to the page.
Asked
Active
Viewed 42 times
-1
-
refer this link http://www.w3schools.com/cssref/playit.asp?filename=playcss_background-size&preval=cover – Udhay Titus Jul 16 '16 at 08:19
-
– Hysteria Jul 16 '16 at 08:26
-
Possible duplicate of [CSS background image to fit width, height should auto-scale in proportion](http://stackoverflow.com/questions/9262861/css-background-image-to-fit-width-height-should-auto-scale-in-proportion) – Cookie Ninja Jul 16 '16 at 08:29
2 Answers
0
You should do this with backgroud-size in css
If you'd like to use CSS3, you can do it pretty simply using background-size, like so:
background-size: 100%;
in you div you can add the style directly without using a css external file
<div style ="background-size: 100%;" ....> .... </div>

ScaisEdge
- 131,976
- 10
- 91
- 107
-
i know it but i just want to know if there any other way using html ? like body backgroung="png.png" height="100%" width ="100%" – Hysteria Jul 16 '16 at 08:21
0
You need to make a 100% width b aground which must cover up you complete background. So please add this css in you style.css file.
html {
background: url(yourimage.jpg);
background-size:cover;
}

Siddharth vyas
- 104
- 9