471,599 Members | 977 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,599 software developers and data experts.

CSS simple question?

Using CSS I want to center a DIV on the page and always keep it 3px
from the top. Seems simple but I cannot find a cross-browser solution
to this problem. I can get to work in IE or FF but not both w/o
relaxing the 3px from the top constraint. Can someone offer a solution
to this problem?

Nov 21 '07 #1
3 2031
hzgt9b wrote:
Using CSS I want to
...not multi-post. Cross-post only if absolutely necessary. You have
answers in alt.html (This is Usenet, not Google Groups.)

http://oakroadsystems.com/genl/unice.htm#xpost

--
-bts
-Motorcycles defy gravity; cars just suck
Nov 21 '07 #2
hzgt9b schreef:
Using CSS I want to center a DIV on the page and always keep it 3px
from the top. Seems simple but I cannot find a cross-browser solution
to this problem. I can get to work in IE or FF but not both w/o
relaxing the 3px from the top constraint. Can someone offer a solution
to this problem?
body {
text-align: center;
}
#container {
top: 3px;
width: 700px;
margin: 0 auto;
text-align: left;
}
Nov 21 '07 #3
Roderik wrote:
hzgt9b schreef:
>Using CSS I want to center a DIV on the page and always keep it 3px
from the top. Seems simple but I cannot find a cross-browser solution
to this problem. I can get to work in IE or FF but not both w/o
relaxing the 3px from the top constraint. Can someone offer a solution
to this problem?

body {
text-align: center;
}
This is incorrect. text-align property aligns *text* not block elements.
To center a block element within its container set a width to the block
element and set the right and left margins to auto...
#container {
top: 3px;
width: 700px;
margin: 0 auto;
text-align: left;
}
The problem most likely is IE's 3-pixel bug and your solution relies on
quirks mode so it is unlikely to solve the problem

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
Nov 21 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Patchwork | last post: by
1 post views Thread by Proteus | last post: by
2 posts views Thread by Raskolnikow | last post: by
3 posts views Thread by Peter | last post: by
7 posts views Thread by abcd | last post: by
14 posts views Thread by Giancarlo Berenz | last post: by
30 posts views Thread by galiorenye | last post: by
10 posts views Thread by Phillip Taylor | last post: by
17 posts views Thread by Chris M. Thomasson | last post: by
2 posts views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Anwar ali | last post: by

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.