General Question

polycinco's avatar

Using css how can I make my background fit to the screen automatically?

Asked by polycinco (187points) February 28th, 2010

I’m trying to build my web page but I’m having problems with the background, I don’t know how to make it fit all screens sizes but I don’t know how.

Observing members: 0 Composing members: 0

9 Answers

aeschylus's avatar

I would be better able to help you if you could be slightly more specific. Are you using as image as your background? A gradient? Some code or a link would also help. Hope to hear back from you soon!

polycinco's avatar

polycinco.com

I don’t know if the error is fixed or not? I’m still working on it, the bacground image, the dots that increase I don’t know if you can see it?

wenn's avatar

HTML:
<img id=“background” src=“images/dots.gif” alt=”” />

CSS:
* {padding: 0; margin: 0;}
#background{ height:100%; position:absolute; width:100%; z-index:1; }

you could also put the image in a div with id=“background” instead of the image and get the same result.

polycinco's avatar

ok I will do that, thank you

ETpro's avatar

@polycinco Will the graphic seamlessly tile?

Vincentt's avatar

@wenn Why wouldn’t you just add in CSS:

body{
background: #FFF url(‘images/dots.gif’) repeat-x;
}

?

Or perhaps:

body{
background-image: url(‘images/dots.gif’);
background-repeat: repeat-x;
}

In other news, I really wouldn’t use that as background. It might be bearable if you overlay another area with a neutral background (i.e. single-colour or slightly varying gradient), but even then so much contrast on such a small area is really distracting from the real content.

polycinco's avatar

ok thank you, Ill have that in mind

wenn's avatar

@Vincentt reread the question. He stated ”...fit to screen automatically”. In other words scale to fit different screen sizes.

You can’t set the width/height to a background image directly, it has to be applied to and <img /> itself or the containing element in which that <img /> is located.

Vincentt's avatar

@wenn Hmm, but looking at the question is doesn’t look like it has to be streched (i.e. make the dots really wide on wide screens). It seems to me like this kind of image perfectly well qualifies for repeating horizontally by making the left and right edges fit together.

Answer this question

Login

or

Join

to answer.

This question is in the General Section. Responses must be helpful and on-topic.

Your answer will be saved while you login or join.

Have a question? Ask Fluther!

What do you know more about?
or
Knowledge Networking @ Fluther