1

I'm trying to make my webpage. I made a layout using Photoshop so effectively, it is a PNG file.

My question is - How do I integrate this into the website using HTML/CSS? I tried editing the css which kind of worked.

body {
background-image:url('URLAddressHere');
}

However, when I enlarge the window, etc, etc... the image just gets ruined. Is there a way for the background to scale properly with page size? Also, I want it to stay uniform (i.e. it does not repeat) Or am I just doing it wrong? How am I meant to implement this 'image' which essentially has my menu, etc.

Thanks

user432584920684
  • 379
  • 1
  • 8
  • 19
  • use a "div" to wrap background image and outside this "div" use a color or repeated image. – Mosijava Mar 24 '12 at 09:04
  • http://stackoverflow.com/questions/376253/stretch-and-scale-css-background http://stackoverflow.com/questions/1150163/stretch-and-scale-a-css-image-background-with-css-only http://css-tricks.com/how-to-resizeable-background-image/ – hkulekci Mar 24 '12 at 09:06

4 Answers4

0

Try this:

body {
    background-image:url('URLAddressHere');
    background-repeat:no-repeat;
}
Barry Kaye
  • 7,682
  • 6
  • 42
  • 64
Josh
  • 2,835
  • 1
  • 21
  • 33
0

What you're looking for is a css3 property called background-size. This will resize the background depending on the width and height of the browser. I have linked a few resources below. You will also need to turn repeat off. Enjoy

http://www.css3.info/preview/background-size/

So for your class you may want to add:

background-repeat: no-repeat;
background-size: cover;
nickw444
  • 948
  • 2
  • 9
  • 18
0

I think you'll want something like this....

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;
    filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/bg.jpg', sizingMethod='scale');
    -ms-filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/bg.jpg', sizingMethod='scale')";
}
Greg
  • 31,180
  • 18
  • 65
  • 85
-3
<body style="background-color:powderblue;">

Is this what you are looking for?

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
  • The question is about scaling the image correctly which is not reflected in your answer. Maybe you can update it? – Henridv May 06 '21 at 08:11