By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,453 Members | 961 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,453 IT Pros & Developers. It's quick & easy.

Divs centreing in Firefox/Chrome but not IE

P: 1
Good Evening

I am building a website using DIVs and CSS.

I have everything in a container DIV, which I want to centre on the page. The CSS is below:

Expand|Select|Wrap|Line Numbers
  1. #container{ 
  2.     width: 100%;
  3.     max-width: 1000px;
  4.     width:expression(document.body.clientWidth > 1000? "1000px": "auto" );
  5.     float: center;
  6.     color: #fff;    
  7.     margin-left: auto;
  8.     margin-right: auto;
  9.     padding: 0px;
  10.     border-width: 0px
  11.         } 
Yet for some reason, in IE it won't center. Any idea why?

On a similar vein, within the container I have a navigation bar. For some reason, it just won't center. I thought it was because it was a <ul> and then indented, but I have tried setting margin and padding to zero.

Any ideas?

Code below:

Expand|Select|Wrap|Line Numbers
  1. #navbar ul {
  2.     margin-left: 0px;
  3.     margin-right: 0px;
  4.     padding-left: 0px;
  5.     padding-right: 0px;
  6.     height: 27px;
  7.     list-style-type: none;
  8.     text-align: center;
  9.     font-weight: bold;
  10.     font-size: 13px;
  11.     border-width: 0px
  12.         } 
  13.  
  14. #navbar ul li {  
  15.     display: inline;
  16.     height: 25px;
  17.     width: 100px;
  18.     text-align: center;
  19.     border-width: 0px
  20.         } 
  21.  
  22. #navbar ul li a { 
  23.     float: left;
  24.     width: 100px;
  25.     margin-left: 10px;
  26.     margin-right: 10px;
  27.     text-decoration: none;
  28.     display: inline;   
  29.     line-height: 25px;
  30.     color: #fff; 
  31.     border-width: 0px;
  32.     background: url("buttons.jpg") no-repeat 0 0
  33.         } 
Thanks
Chris
Mar 30 '11 #1
Share this Question
Share on Google+
1 Reply


drhowarddrfine
Expert 5K+
P: 7,435
In the first, there is no such thing as 'float:center'. Also, Microsoft dropped support for 'expression' in IE8.
Mar 30 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.