Forum Moderators: not2easy

Message Too Old, No Replies

CSS to put a border around a centered page?

         

ealvin

4:26 am on Jul 31, 2005 (gmt 0)

10+ Year Member



I don't really know much about CSS but I've been advised how to center my website and put it in a container. My page appears to "float" in the middle of the browser. I'd like to add a color to the side panels to make the page stand out more. Could you please give me the CSS and any code I need to make this change (as well as telling me where to insert it)?

Thanks for your help.

SuzyUK

9:08 am on Jul 31, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi ealvin and Welcome to the forums!

we would really need a bit more information than that (not a site link though!)

e.g. are the "side panels" inside the container or are you referring to the body background that is still showing outside the container.

if you can post what CSS/HTML you have for the bare bones outline (no content or links required) and add some colours to help describe what you'd like to achieve I'm sure someone would manage to offer some pointers.

Suzy

ealvin

5:51 pm on Jul 31, 2005 (gmt 0)

10+ Year Member



Thanks Suzy for your reply. Sorry for not making myself clearer.

I have the page at 600 (so it's a bit narrow) in a "container" and it fits "inside" the screen, sort of floating in the middle of the page. There are no vertical lines signifying the borders and there is white space (even though the page is also white) out to the right and left of the page. So I'm talking about the background that is outside the container, I guess. :)

I'd like to have the vertical lines on the side of the page and use a different color (choose any color and I'll change it later) on the sides on the outside of the page. I see this often and my hope is this will make the page standout on the screen.

Here is the CSS...

body, table { margin:0px; padding:0px; background:#ffffff; color:#000000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size: 12pt;}

a { color:#0000aa; text-decoration:underline; }
a:hover { text-decoration:underline; }

h1 { font-family:Tahoma; font-size:14pt.; font-weight:bold; color:#000080;}
h2 { font-family:Tahoma; font-size:12pt.; font-weight:bold; }

#title { color:#ccf; font-weight:bold; font-family:serif; font-size:35px; padding:10px; }
#heading { background:#ffffff; padding:20px; height:180px; }
#mainText { padding:10px; padding-top:0px; vertical-align:top;}
#linkList { background:#f0ffff; padding:10px; }
#boxed { border:#555555 solid 1px; padding:10px; }

#column1 { vertical-align:top; }
#column2 { vertical-align:top; width:180px; border:#555 solid 1px; background:#f0ffff; /*previously #eeeeee */}

#privacy { font-size:10px; }

.highlight { background:#ffff00; }
.nounderline { text-decoration:none; }
.yellowBlock { background:#ffffcc; }

I'm not sure what to post of the HTML, but hopefully the CSS will give you what you need.

Also, is it a "no-no" to post the link (that could make it easier to see the HTML)?

Thanks again, I'm glad to be hear and appreciate any help one can offer.

MWpro

6:27 pm on Jul 31, 2005 (gmt 0)

10+ Year Member



What I think you are asking, is how to add a left and right border to your page.

Wrap everything in a div and give it border properties:

<div id="border">
rest of page here
</div>

then the css would look like this
#border {
border-left: 1px solid #000;
border-right: 1px solid #000;
}

ealvin

8:16 pm on Jul 31, 2005 (gmt 0)

10+ Year Member



Thanks, yes that is what I want.

I made the change and I assumed the #000 could be replaced by the color I wanted to use for the borders, which in this case was #000080. Yet when I look at the page I see the vertical lines but the borders are still white. How do I make them the color I want?

tedster

10:16 pm on Jul 31, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The vertical lines you see, technically, ARE the borders. You may be using the word border in a common-speech manner to mean what you called "side panels".

I'd like to add a color to the side panels to make the page stand out more.

Try changing the background-color in your <body> tag to your chosen "side panel" color - and add a background-color:#fff; rule to the new #border div you created.

To get the exact look you are after, you may need to reference the "box model" that is behind the way browsers render html and css.

Here's an image from the W3C - the board that established the standards for html and css:
[w3.org...]

ealvin

11:43 pm on Jul 31, 2005 (gmt 0)

10+ Year Member



Yes, you indentified it. That's what I want to do. Since I'm not very swift with coding, could you give me the "Dummies" version of the CSS (and HTML, if necessary) code? BTW, my main body color of my page is white and I want the blue I indicated in the post above for the side panels.

Thanks for your help.

tedster

3:17 am on Aug 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Since you have the same rules set for body and table, you can't just change the background-color there without changing TOO much elsewhere on your page -- sorry, I didn't notice that at first.

So, try this. On a new line, immediately after the CSS rules that begin body, table paste in this:

body {background-color:#0000cc;}

(or change #0cc to your favorite shade of blue)

Then change the rules for the #border id you created above -- to get rid of those single pixel borders that were not exactly what you had in mind, and to make the rest of the page have a white background.

#border {background-color:#ffffff;}

ealvin

4:21 am on Aug 1, 2005 (gmt 0)

10+ Year Member



Thanks Ted, I believe I understood the first part of your instructions. I added the line you gave me below body, table in the CSS.

I'm not sure about the second part. I replaced (pasted the #border {background-color:#ffffff;}
line over the previous border code in the CSS. Was that where it was supposed go?

I didn't make any changes to the actual HTML page.

Anyway, now I no longer have any borders and all of the page is whilte. In fact, it looks just like it did before I started this thread. What have I done wrong?

tedster

4:57 am on Aug 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Maybe you've done nothing wrong -- your page layout is probably the issue here. If you're not seeing any blue at all, it probably means that <div id=border> is actually filling the whole screen.

What happens if you do this?

#border {background-color:#ffffff;margin:20px;}

ealvin

5:09 am on Aug 1, 2005 (gmt 0)

10+ Year Member



I replaced the old Border code with the new one and it still looks the same. Any other ideas?

tedster

5:46 am on Aug 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



We've got to work with your html to go any further, and definitely not the whole page of code. I understand that you've been using Front Page and are not strong in html knowledge right now, but this is the time to roll up your sleeves and work with it a bit.

Because you are talking about a centered page, I'm guessing there is a top level container (a table or a div most likely) that has width="100%" -- this page container is therefore filling the entire screen so none of the color background show through. From the CSS you pasted in above, I strongly assume it will be a table.

This should be the VERY FIRST <table> or <div> element in your code, not counting the border <div> you experimented with earlier. You can remove that div element (both the opening and closing tags) for now.

Once you locate this first table or div in your original mark-up, add a new attribute style="background-color:#009;" to the inside of the opening tag for that element, so that is looks something like:

<table width="100%" style="background-color:#000099;">
..or..
<div width="100%" style="background-color:#000099;">

...but there may also be other attributes in the tag as well. Just let them alone, making sure that a space separates each attribute from the next.

I don't know if this alone will be the complete fix. It might be, or it might turn more of your page blue than you want. If that happens, then we'll need to turn the rest of the background back to white. In that case we would want to find the very next <table> or <div> in the html, and give it a similar treatment but with a white background-color.

<table width="100%" style="background-color:#ffffff;">
..or..
<div width="100%" style="background-color:#ffffff;">

If your page stgructure is relatively basic, this should at least get you close to what you want -- let us know. If it isn't close, then your html layout is more complex (I am assuming something pretty simple) and we'll have to take it from there.

ealvin

6:14 am on Aug 1, 2005 (gmt 0)

10+ Year Member



I didn't have any success. I searched my HTML for 100% and it didn't find anything. When I searched for div I had div id for container and border. There was also was also one for main text (I have a large main text area and then a 2nd column on the right). It didn't have any width designations.

When I search for "table" I only find a closing tag at the bottom of the page. The first reference close to it at the top of the page is this...

<table cellspacing="0" cellpadding="0">
<tr>
<td id="column1">
<div id="mainText">
<font face="Arial, Helvetica">

So I haven't made any changes. BTW, would it be easier if I posted on sent you my URL so you could see the source code?

Thanks for your help and bearing with me. I know it's not easy but I do appreciate your help.

ealvin

6:25 am on Aug 1, 2005 (gmt 0)

10+ Year Member



Oh, BTW...for some reason, when I go to Preview in FP (and just now when I ftp'd my site change for the headline problem from my other post) my headlines are taking several seconds to load. Before they were instantaneous. I just thought you'd want to know.

tedster

8:12 am on Aug 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



When I search for "table" I only find a closing tag at the bottom of the page. The first reference close to it at the top of the page is this...

<table cellspacing="0" cellpadding="0">

Those two statements contradict each other, ealvin. Maybe use a computerize search in addition to looking visually.

ealvin

5:14 pm on Aug 1, 2005 (gmt 0)

10+ Year Member



Actually that's what I did. I used Search inside FrontPage (I also visually searched before that). I could be wrong Ted (wouldn't be the first time :) ) but I think what I said was accurate. What sould I do next?

tedster

6:04 pm on Aug 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As I said earlier, something here is not accurate -- you found an early opening table tag that you pasted in above, even though your "search" found only a later closing tag near the bottom of the page.

Unless your html is pretty butchered, there IS an earlier opening table tag on the page to match each and every closing tag -- and you need to find the first such tag. Try this -- locate the opening tag for BODY and then read slowly and carefully forward from there. You should find the first opening table tag really quickly.

Or perhaps you can do a computerized search for <table (note, no closing bracket). However, given your earlier results with FrontPage search I would feel better at this point if you do a visual inspection.

ealvin

7:45 pm on Aug 1, 2005 (gmt 0)

10+ Year Member



When I did my first search prior to your last post, I just searched for "table," I didn't copy from the source code into the Find text area. This time I visually searched and did the search <table you recommended and the only thing I found was what I mentioned previously...

<table cellspacing="0" cellpadding="0">

I'm pretty sure there is nothing before this. Sorry this is so difficult.

tedster

9:14 pm on Aug 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sorry this is so difficult.

No worries - as you learn more you will find it easier and easier to describe things related to your html code. And truthfully, you can only get the best out of FrontPage if you also know a bit about html and css, so this is a good exercise.

Let's try this approach:

1. Find the opening <body> tag
2. Copy everything from that tag up to and including the <table cellspacing="0" cellpadding="0"> tag
3. Paste just that piece of your html into your next post - but change any domain name in there to "example.com"