user3435927
user3435927

Reputation: 1

HTML and CSS background image scaling to fit screens

I am currently working on building my portfolio website. I am using HTML and CSS. I have an image I am using for my background but the background remains the same size regardless of the size of the screen. What code should I use? Should I upgrade my code to CSS3/HTML5 and if so what would be the code for that? Thank you very much for your time and help ahead of time, this is a detail that is driving me nuts and a huge hang up when showing my work.

Upvotes: 0

Views: 34276

Answers (2)

manosim
manosim

Reputation: 3680

Have a look at the code below:

html { 
  background: url(images/bg.jpg) no-repeat center center fixed; 
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}

Upvotes: 2

ProllyGeek
ProllyGeek

Reputation: 15836

background-size : 100% auto

this gonna set width to 100% and height to auto

always search well before you post a question , this might be a good reference as a beginner :

http://www.w3schools.com/cssref/css3_pr_background-size.asp

Upvotes: 3

Related Questions