| | |
Centering CSS
Please support our HTML and CSS advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Sep 2006
Posts: 162
Reputation:
Solved Threads: 14
Suppose there is a very simple web page.
How would i go about centering these acurately considering differing screen configurations?
Thanks.
HTML and CSS Syntax (Toggle Plain Text)
<html> <head> <style type="text/css"> #logo{ background-color: red; position: absolute; top: 0px; left: 0px; width: 100px; height: 100px; } #banner{ background-color: blue; position: absolute; top: 0px; left: 100px; width: 500px; height: 100px; } #content{ background-color: green; position: absolute; top: 100px; left: 0px; width: 600px; height: 400px; } </style> </head> <body> <div id="logo"></div> <div id="banner"></div> <div id="content"></div> </body> </html>
How would i go about centering these acurately considering differing screen configurations?
Thanks.
Two ways:
1 Use Tables
2. Use CSS
[
http://www.simplebits.com/notebook/2...centering.html
http://www.maxdesign.com.au/presentation/center/
]
These links may help
1 Use Tables
2. Use CSS
[
http://www.simplebits.com/notebook/2...centering.html
http://www.maxdesign.com.au/presentation/center/
]
These links may help
This works, just added the wrapper
change the heights and width and margins according to your needs
change the heights and width and margins according to your needs
html Syntax (Toggle Plain Text)
<html> <head> <style type="text/css"> #wrapper{ width:500px; height:500px; position:relative; margin-left:-250px; left:50%; margin-top:-250px; top:50%; } #logo{ background-color: red; position: absolute; top: 0px; left: 0px; width: 100px; height: 100px; } #banner{ background-color: blue; position: absolute; top: 0px; left: 100px; width: 500px; height: 100px; } #content{ background-color: green; position: absolute; top: 100px; left: 0px; width: 600px; height: 400px; } </style> </head> <body> <div id="wrapper"> <div id="logo"></div> <div id="banner"></div> <div id="content"></div> </div> </body> </html>
GiorgosK
Web developer/marketer
------------------
Free online games Chios studios Chios Apartments Chania studios Chios Greece travel guide
Web developer/marketer
------------------
Free online games Chios studios Chios Apartments Chania studios Chios Greece travel guide
•
•
Join Date: Sep 2006
Posts: 162
Reputation:
Solved Threads: 14
GiorgosK that works great in IE but it doesn't render properly in Firefox. I'll mess around with it a bit to see if i can get it to work.
This is what i have using the other way.
The problem i'm having is that the container div positions the other divs one on top of the other instead of this...
1122222
1122222
3333333
3333333
3333333
I think it's got something to do with the position attribute but i'm not making sense of them yet. Any suggestions anyone?
This is what i have using the other way.
HTML and CSS Syntax (Toggle Plain Text)
<html> <head> <style type="text/css"> body{text-align: center;} #container{ margin: 0 auto; width: 600px; height: 600px; text-align: left; border-top: 1px solid blue; border-bottom: 1px solid blue; border-right: 1px solid blue; border-left: 1px solid blue; } #logo{ background-color: red; top: 100px; left: 0px; width: 100px; height: 100px; } #banner{ background-color: blue; top: 0px; left: 100px; width: 500px; height: 100px; } #content{ background-color: green; top: 100px; left: 0px; width: 600px; height: 600px; } </style> </head> <body> <div id="container"> <div id="logo"></div> <div id="banner"></div> <div id="content"></div> </div> </body> </html>
The problem i'm having is that the container div positions the other divs one on top of the other instead of this...
1122222
1122222
3333333
3333333
3333333
I think it's got something to do with the position attribute but i'm not making sense of them yet. Any suggestions anyone?
I did not check it with firefox actually
put this in the style tag
body, html {
height:100%;
}
it should work with Firefox now
put this in the style tag
body, html {
height:100%;
}
it should work with Firefox now
GiorgosK
Web developer/marketer
------------------
Free online games Chios studios Chios Apartments Chania studios Chios Greece travel guide
Web developer/marketer
------------------
Free online games Chios studios Chios Apartments Chania studios Chios Greece travel guide
No problem Cerberus,
rep is always appreciated if you did find my post valuable.
rep is always appreciated if you did find my post valuable.
GiorgosK
Web developer/marketer
------------------
Free online games Chios studios Chios Apartments Chania studios Chios Greece travel guide
Web developer/marketer
------------------
Free online games Chios studios Chios Apartments Chania studios Chios Greece travel guide
![]() |
Similar Threads
- How to center align the whole page? (HTML and CSS)
- Have a problem with centering "jpg" files (HTML and CSS)
Other Threads in the HTML and CSS Forum
- Previous Thread: Text is dropping out of place
- Next Thread: Don't know where to post this website question...
| Thread Tools | Search this Thread |
appointments asp background backgroundcolor beta browser bug calendar cart cgi code codeinjection corporateidentity css design development displayimageinsteadofflash dreamweaver emailmarketing epilepsy explorer firefox flash form format google griefers hackers hitcounter hover html ide ie7 ie8 iframe image images internet internetexplorer intranet iphone javascript jpeg layout macbook maps marketshare microsoft mozilla multimedia navigationbars news offshoreoutsourcingcompany opacity opera optimization pnginie6 positioning problem scroll seo shopping studio swf swf. textcolor timecolor titletags url urlseparatedwords visual visualization web webdevelopment webform website windows7






