Help with CSS

All off topic discussions go here. Everything from the funny thing your cat did to your favorite tv shows. Non-programming computer questions are ok too.
Post Reply
srg_13

Help with CSS

Post by srg_13 »

Hi,
I am developing a new web site, but I have run into a problem, and was wondering if it was possible to fix it. I have an area of text in between two <div> tags. In the CSS stylesheet, I specify a background for that div's id. The problem that I am having is that I cannot got the image to scale in the background. I have searched Google for it, but I could not find any answers.

Thankyou in advance,

-Stephen
iammisc

Re:Help with CSS

Post by iammisc »

width and height should both be set to 100%.
srg_13

Re:Help with CSS

Post by srg_13 »

How do you do that? It seems that the background property only has these properties:

Code: Select all

background-color
background-image
background-repeat 
background-attachment 
background-position
How do you set the width and height?

-Stephen
Cjmovie

Re:Help with CSS

Post by Cjmovie »

The only thing I can think of:

div.Container {
width: 100%;
height: 100%;
position: relative; /* important! */
}
img.Inside{
width: 100%;
height: 100%;
position: absolute;
left: 0px;
top: 0px;
z-index: 0;
}
div.Inside{
width: 100%;
height: 100%;
position: absolute;
left: 0px;
top: 0px;
z-index: 1;
}

then do this, replacing [ with < and ] with >:

[div class="Container"]
[img class="Inside" src="..." /]
[div class="Inside"]
This is some text this is some text more text more text
[/div]
[/div]

See what I'm getting at?
srg_13

Re:Help with CSS

Post by srg_13 »

Thanks for that. I'll try it out soon.

-Stephen
srg_13

Re:Help with CSS

Post by srg_13 »

OK, I have another question:

My site is contained in a div tag, that has padding and widths and things like that defined. Is it possible to make this float in the centre of the page, without using the HTML center tag? I have tried this:

Code: Select all

<div id="container" align="center">

<!-- Website code -->

</div>
but that made everything (text, images etc.) centered, which I do not want.

Thanks,

-Stephen
The Polar One

Re:Help with CSS

Post by The Polar One »

Set your margins to auto and make sure you specify your width.

#container {
   width:500px;
margin:0px auto auto;
   }

Should keep it central.
srg_13

Re:Help with CSS

Post by srg_13 »

Thanks, that works great!

-Stephen
Post Reply