Forum Moderators: not2easy
I have a page with a background color of blue. The content of the page is centered, via CSS. I would like the container that holds the centered content to be white. I can't seem to figure out how to get it to work. I tried inserting background:white into my style sheet for the appropriate container, to no avail. I'm obviously doing something wrong... Any help available?
Thank you
Css can be tricky to pick up.
To have a centered div with a background colour try:
the css:
body
{
text-align:center;
background:#14008F
}
#content
{
background:#fff;
width:750px;
margin:0 auto;
text-align:left
}
the html:
<body>
<div id="content">
<p>Some content goes here.</p>
</div>
</body>
Whats happening here is, everything in the body is centered (to center your content div) and applying a margin of 0 auto to the content div ensures it is slap bang in the middle. Applying a text-align:left to the content div ensures all your content is left aligned.
Hope this helps :)
<B>CSS</B>
body
{
text-align: center;
background-color: #001f3e;
}
#content
{
background-color: #fff;
margin: 0 auto;
width: 779px;
text-align: left;
position: relative;
}
#leftbar
{
display: block;
background-color: #fff;
position: absolute;
top:25px;
width: 122px;
height: 397px;
padding: .2em .2em;
text-decoration: none;
left: 2px;
}
#scenetofolder
{
background-color: #fff;
text-decoration: none;
position: absolute;
top:25px;
left: 180px;
width:593px;
}
<B>HTML</B>
<body>
<div id="content">
<div id="leftbar" style="background-image: url('tabtools.jpg');">
<center><BR><BR><A Href="/availablehomes.shtml"><center>Find a Norfolk Home</A>
<BR><img src="smallmichigan5.jpg" width="100" height="126">
<BR><br><img src="divider.jpg" width="104" height="18">
<br><br><A Href="/mortgagecalculator.shtml"><center>Mortgage Calculator</A>
<BR><br><img src="divider.jpg" width="104" height="18">
<br><A Href="/mortgagecalculator.shtml">Warranty Service</A></center>
</div>
<div id="scenetofolder">
<Style="text-decoration:none"><img src="fireanimation.gif" name='SlideShow' width="593" height="395" usemap="#foldermap">
</div>
<div id="bottomleft" style="background-image: url('tablef.jpg'); no-repeat" align="center"> <br><br><br>
<P ALIGN=center><IMG SRC="balatext.jpg" BORDER=0 NAME="slide"></P>
</div>
<div id="bottomright" style="background-image: url('tabrigh.jpg'); no-repeat" align="left">
<br>       <img src="arrow.gif">Custom and Semi-Custom Homes: Build your dream <br>       home on <I>your</I> homesite. View our collection of homes.
<br><br>       <img src="arrow.gif">View photographs of homes during the build <br>       process: <a href="http://www.mynorfolkhome.com">www.mynorfolkhome.com </A>
</div>
</div>
</body>