Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

General discussion

CSS coding question...

Oct 4, 2005 7:42AM PDT

Hey,
I have a site that has a body css style in it, that implements a background image that sits fixed on the bottom right hand corner, and a DIV centering for the page. Problem is, they both can't work together in my coding:
<style type="text/css">
body
{text-align: center;
}
{
background: #000000 url('azbg.gif') no-repeat fixed bottom right;
}
.centered80
{
position: absolute;
left: 10%;
right: 10%
}
#container {
margin: 0 auto;
width: xxxpx;
text-align: left;
}

</style>

Strangely enough, however, I can switch the background coding before the centering coding and the background will work but the centering will not, and vice versa, such as the coding given above. Is there a way I could fix this?
For examples, visit http://amethystzazzle.com/buttons.php (background) or http://amethystzazzle.com/test.php (centering).

Thank you for your help!

Discussion is locked

- Collapse -
Remove the {s between the text-align and background
Oct 5, 2005 8:13PM PDT

For the rest of it, do you have a link so we can see the whole thing?

- Collapse -
Also........
Oct 7, 2005 10:25PM PDT

I'm just learning CSS, so I may be way out here. But also you have this entry;

}
.centered80
{

which means the ".centered80" element has not been enclosed within curly brackets, or you are using nested curly brackets where one of the brackets is missing. If you are using nested brackets, I'm not sure that is allowed in CSS.

But like I say, I'm just a beginner, Happy

Mark

- Collapse -
.centered 80
Oct 11, 2005 9:55PM PDT

would be a class he has assigned to some element and only its definition should be enclosed in {s, not the class itself.

- Collapse -
Yeah
Oct 7, 2005 11:05PM PDT

Basically what the other two said...

<style type="text/css">
body
{text-align: center;
}
{
background: #000000 url('azbg.gif') no-repeat fixed bottom right;
}
{
.centered80
}
{
position: absolute;
left: 10%;
right: 10%
}
#container {
margin: 0 auto;
width: xxxpx;
text-align: left;
}

</style>

...You needed brackets before and after the .centered80

- Collapse -
Never mind
Oct 7, 2005 11:07PM PDT

Sorry, I just reread your coding and realized what you were trying to do...

<style type="text/css">
body{text-align: center;background: #000000 url('azbg.gif') no-repeat fixed bottom right;}

.centered80{position: absolute;left: 10%;right: 10%}

#container {margin: 0 auto;width: xxxpx;text-align:left;}

</style>

I don't assume that would work? What is the .centered80 for anyhow?

- Collapse -
to center a div....
Nov 10, 2005 5:49AM PST

#divisionID {

position:absolute;
left:50%
top:50%
width:500px;
heught:500px;
margin-top:-250px;
margin-left:-250px;

}

That will center the division in the page both horizontilly and vertically, remember to take half the width/height to set nargins.