0

I am trying to make by background image fit to the screen, but I'm not sure what to add to my code.

<body background= "b.png">

If anyone could suggest what to put and where that would be great.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
ablyn02
  • 1
  • 2
  • 1
    possible duplicate of [CSS: stretching background image to 100% width and height of screen?](http://stackoverflow.com/questions/22887548/css-stretching-background-image-to-100-width-and-height-of-screen) – NightShadeQueen Jul 28 '15 at 16:07

2 Answers2

0

Apply the following CSS to your body tag in your stylesheet. You can change the value of the properties to match how you want you background to look.

body {

    margin:0;
    padding:0;
    background-image: url(b.png);
    background-repeat: repeat-y;
    background-attachment: fixed;
    background-position: top center; 
    background-size: cover;
    -webkit-background-size:cover;
    width: 100%;
    height: 100%;
    min-width: 100%;
    min-height: 100%;
    -webkit-background-size: auto auto;
    -moz-background-size: auto auto;
    -o-background-size: auto auto;
    background-size: auto auto;
    position:relative;  

}
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Connor
  • 3
  • 3
0

As mentioned in one of the comments, put this into the CSS:

body {
    background-image:url("../images/myImage.jpg");
    background-repeat: no-repeat;
    background-size: 100% 100%;
}

html {
    height: 100%
}
jenlky
  • 396
  • 5
  • 22