473,721 Members | 2,233 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get centered div with 1px border?

I'm trying to get a 1px border around the content section of this page:

http://www.clearpointsystems.com

As you will see, I have a header/nav bar (looks correct), but the border around
the content is not centered and does not resize properly as the browser window
is resized.

The goal is a 1px border around the content (div id="page") with about 30px (or
2%) margin all around and the border/content should resize as the browser
window is resized.

What I have now is something of a hack:

#page {
position:absolu te;
top:80px;
width:80%;
height:50%;
font-family:Arial, Helvetica, sans-serif;
border: 1px solid #333333;
text-align:left;
margin-top:0 auto 0 auto;
padding:30px 30px 30px 30px;
}

How do I get a centered div with an evenly-spaced 1px border all around?

Thanks in advance.

Jun 7 '06 #1
12 2767
Once upon a time *deko* wrote:
I'm trying to get a 1px border around the content section of this page:

http://www.clearpointsystems.com

As you will see, I have a header/nav bar (looks correct), but the border around
the content is not centered and does not resize properly as the browser window
is resized.

The goal is a 1px border around the content (div id="page") with about 30px (or
2%) margin all around and the border/content should resize as the browser
window is resized.

What I have now is something of a hack:

#page {
position:absolu te;
top:80px;
width:80%;
height:50%;
font-family:Arial, Helvetica, sans-serif;
border: 1px solid #333333;
text-align:left;
margin-top:0 auto 0 auto;
padding:30px 30px 30px 30px;
}

How do I get a centered div with an evenly-spaced 1px border all around?

Thanks in advance.

#page {
width:80%;
height:50%;
font-family:Arial, Helvetica, sans-serif;
border: 1px solid #333333;
text-align:left;
margin:0 auto;
padding:30px;
}

You can't use "position:absol ute;" so you don't need the "top:80px;"
Set the margin-top to something more than "0" if you like, but that is
only for the top margin and nothing else. Bottom, left and right margin
is a different matter. "margin:0 auto;" set the top and bottom margins
to 0 and "auto" is centering the div horizontaly, if that is your goal?

--
/Arne

Proud User of SeaMonkey. Get your free copy:
http://www.mozilla.org/projects/seamonkey/
Jun 7 '06 #2
deko wrote:
I'm trying to get a 1px border around the content section of this page:

http://www.clearpointsystems.com

How do I get a centered div with an evenly-spaced 1px border all around?


Replace all of your stylesheet with this (don't use abs pos):

body {margin:0;font-size:small;}
#header {width:100%;mar gin:0;padding:1 0px 0 9px 0;
font-family:Arial, Helvetica, sans-serif;
font-size:16px;font-weight:bold;tex t-transform:upper case;
letter-spacing:.2em;ba ckground:#E8E7D D;text-align:center;}
#navtable a:link { color:#FFFFFF; text-decoration:none ; }
#navtable a:visited { color:#FFFFFF; text-decoration:none ; }
#navtable a:hover { color:#003300; text-decoration:none ; }
#navtable td {background-color:#00CC33; /* green */
text-align:center;fo nt-size:12px
font-family:Verdana, Arial, Helvetica, sans-serif;}
#sidebar {background:#E8 E7DD;font-family:Verdana, Arial, Helvetica,
sans-serif;
float:right;wid th:190px;margin :0;padding:15px ;}
#page {width:80%;font-family:Arial, Helvetica, sans-serif;
border: 1px solid #333333;text-align:left;
margin:0 auto;padding:30 px;}

--
Gus
Jun 7 '06 #3
>> http://www.clearpointsystems.com

How do I get a centered div with an evenly-spaced 1px border all around?


Replace all of your stylesheet with this (don't use abs pos):


That looks great!

This was my first attempt at using a table navbar. I like the idea because
there are no images - keeps page size down. But I thought I needed to use
absolute positioning to get that header right.

What's wrong with absolute positioning? I've had pretty consistent results in
FF and IE.

Thanks for the help!

PS. You can see the changes online - I am working on that sidebar at the
moment...

Jun 8 '06 #4
deko wrote:
http://www.clearpointsystems.com

How do I get a centered div with an evenly-spaced 1px border all
around?


PS. You can see the changes online - I am working on that sidebar at
the moment...


May I invite you to see this page, about fonts and sizing?
http://k75s.home.att.net/fontsize.html

--
-bts
-Warning: I brake for lawn deer
Jun 8 '06 #5
> May I invite you to see this page, about fonts and sizing?
http://k75s.home.att.net/fontsize.html


Thanks for the tip. I'm using 'font-size:small' (and medium, large) which seems
to get me by in most cases. As for Veranda, I have no special attachment to it,
though it is readable. Trebuchet MS might be alternative. What do you suggest?

Jun 8 '06 #6
Deciding to do something for the good of humanity, deko
<de**@nospam.co m> declared in
comp.infosystem s.www.authoring.stylesheets:
As for Veranda, I have no special attachment to it,
though it is readable. Trebuchet MS might be alternative.
What do you suggest?


sans-serif

--
Mark Parnell
My Usenet is improved; yours could be too:
http://blinkynet.net/comp/uip5.html
Jun 8 '06 #7
> sans-serif

yeah... better than Times New Roman
Jun 8 '06 #8
deko wrote:

This was my first attempt at using a table navbar. I like the idea
because there are no images - keeps page size down.
Funny thing is that I see 5 calls for _s1.gif_ in your table.
But I thought I
needed to use absolute positioning to get that header right.
Live and learn. ;-)
What's wrong with absolute positioning?
Nothing actually, but don't use it if you don't have to and you don't
have to in most instances.
You have to understand that an absolutely positioned element is out of
the normal flow.
I've had pretty consistent
results in FF and IE.
There is more than one way to skin a cat.
PS. You can see the changes online - I am working on that sidebar at
the moment...


Looking fine here.

--
Gus
Jun 8 '06 #9
deko wrote:
May I invite you to see this page, about fonts and sizing?
http://k75s.home.att.net/fontsize.html
Thanks for the tip. I'm using 'font-size:small' (and medium, large)
which seems to get me by in most cases.


Using the sizing words could present a problem in some browsers. I'd
recommend going with just percentages for sizing. The following should
do it.

body { font-size: 100%; } /* everyone's default size */
h1 { font-size: 140%; } /* <-- or similar for headings */
h2 { font-size: 125%; }
h3 { font-size: 115%; }
..legalese { font-size: 85%; }

If 100% looks too large to you, reset your own browsers' default sizes.

Use em units for the sizing of <div>s (so they expand with the text when
the visitor resizes) and only use pixels (px) for explicit borders if
necessary. There should be no need for px for anything else, in most web
pages.
As for Veranda, I have no special attachment to it, though it is
readable. Trebuchet MS might be alternative. What do you suggest?


I have a couple of sites where I use:
font-family: "Trebuchet MS", Helvetica, Arial, sans-serif;
and that seems to work well.

--
-bts
-Warning: I brake for lawn deer
Jun 8 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1943
by: VRandy | last post by:
Example: http://pages.prodigy.net/randyv/centerprb.htm The desired effect is a fixed width left margin with a fixed width div centered in the right side. If the browser is resized to become very narrow (less than 640px in this example), the right side centered div should stop at the margin and horizontal scroll bar appear as the window gets extremely narrow. IE6 and Opera 4.11 display all the examples the same way. The top row is a...
5
2494
by: Haines Brown | last post by:
I want a centered body, 680px wide, having a red bottom margin. The following works well in galeon, but not in IE5, where the bottom margin steals the full width of the viewpoint. That is, the red line stretches from one side of the screen to the other and is not 680 pixels long. Why isn't the bottom margin 680 pixels? body { ... width: 680px; margin-top: 1em;
2
5486
by: David Winter | last post by:
This is a totally trivial CSS problem, I'm sure, but I don't get it. I want a centered DIV with a fixed width between two other DIVs that should fill the rest of the window/viewport (= 100%). How do I achieve this? I tried width:auto for the buffer DIVs, but it didn't work. This should at least work in IE 5.5 and Opera. A totally standards-compliant solution would be appreciated, of course ... :/ This is waht I have:
3
1466
by: Ernst | last post by:
I have a script for a menu. However, this menu uses absolute coordinates. This menu had to be placed on a website. This website is position (centered) using a table. How can I determine/calculate where to fix my menuregardless the browser, slidebar width, tool etc. Thanks Ernst
7
8822
by: TomB | last post by:
Hello, First of all, I'm just starting to use CSS so I am by no means experienced in this matter. What I want is a "box" div element that always is centered on the page. Now I just use the center tag around my boxes, but I'm pretty sure there must be a way to include the center positioning into the style code. Anyone? Also I had some people complaining about the colours of my site. I'm using red (#6B0000) links on a black background,...
5
4555
by: Chris Beall | last post by:
Objective: Using an HTML list, create a horizontal nav menu with these characteristics: - All menu items have the same width at all times. - When the window width is reduced, the menu items stack, rather than creating a horizontal scroll bar. - The menu cluster is always centered on the window. See http://pages.prodigy.net/chris_beall/Demo/centered%20horizontal%20list.html
4
2657
by: Austin Powers | last post by:
I want to (on one line) show something like the following ------------------------------------------------------- left centered right ------------------------------------------------------- If I use <hrto draw the lines, then there is too much space between the line and the text If I use a table, then how do I get the right-justified string to be at the
7
2026
by: TheLongshot | last post by:
I just recently converted a few pages of my application to using master pages. Problem is, in all of my content pages, the contents are centered. I can't figure out why. The markup in the content page seems to ignore any attempts to manually align right. So what's the deal?
8
1649
by: yoderpd | last post by:
Hello. I'm not a CSS genius, but I'm learning by doing. I am creating a website where all the content is within a 650px box that is centered. Within that box, there are 2 columns. The left column will contain the bulk of the content and the right column will act as a sidebar type of thing. Everything looks perfect in Firefox, but whenever I test the page in IE the right column doesn't appear but everything else looks fine. Here is the CSS...
0
8738
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9234
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9150
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6678
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5994
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4501
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4762
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2599
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2146
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.