I am a begginer on coding i learned coding from: ProgrammingKnowledge youtube channel. I want to make a background stretch image it works but it repeats it self. I searched in google none of these work. They just make my text UNDER the background, cover up text. Please could someone tell me the code? the img is in my folder and my code is here: http://pastebin.com/ptybcjcg
3 Answers
I think you mean this. Add this to the css of the thing that has the background:
.classname{
background-size: cover;
}
Another property for background-size that could be what you want is
background-size: contain;
I hope this helps you.

- 1,475
- 3
- 20
- 32
I think you're looking for:
.my-selector {
background-image: url(/path/to/my-image.png);
background-size: cover;
}
This is a pretty new option in CSS, and there's a bug in iOS Safari if the image is on the <body>
HTML tag. It also doesn't work at all in Internet Explorer 8, so you might need a bit of JavaScript to make it work there if you want to support that browser.

- 20,846
- 10
- 65
- 96
Add this if you want the image to be applied to the body and you should be using CSS , not background attribute for the body tag, which is not supported in HTML5. See here.
Add this CSS to your style part in the head
body{
background:url(extremeprison.png);
background-size:cover;
}
and if you use background-size:contain and height of content is longer than the image's height, use background-repeat:no-repeat;
as well, to avoid repetition for the image, if you want.
Also, DO NOT use overly qualified CSS selectors like div.loginsectiontext
, instead, use just .loginsectiontex
which should work just fine and won't add extra selector when it's not required.
And HERE is the whole code updated
One more thing: Try not to forget a ;
ever, since it can be problematic when there are multiple properties and can cause problems for you.
And place <style>
part and the <title>
in the <head>
instead of the body, which is a better practice.
hope it helps :)

- 13
- 8