| | |
Cannot align a DIV
Please support our HTML and CSS advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
Hello everyone....I've been working on the design for my forum on my website and while everything else has gone to plan...one thing hasn't. On my topic page, the DIV with class greybox and id navigationbox that displays the text Home, New Posts, Members, Stats, Rules, etc. just wont align to the center of my 800px wrapper. I realize that it is set to float to the left and this is because for some reason when I don't float it to the left or right, the DIV's border does not display right in any browser (Well, I know it doesn't work in FF or Chrome, and I think it didn't it IE..). When not floated the border doesn't surround the DIV and instead just stretches across the 800px wrapper. Can anyone help me figure out a way to fix this? (And preferably not a non-standard...I know I could use a table with three columns or add a div before it with width of 33.3%)
Thanks Everyone!
P.S. And while your at it..could you tell me how it looks? I'd love to hear some feedback before I actually start the server side of the forum.
Thanks Everyone!
P.S. And while your at it..could you tell me how it looks? I'd love to hear some feedback before I actually start the server side of the forum.
Last edited by FlashCreations; May 23rd, 2009 at 1:28 pm. Reason: Added an ID so it's easier to find...and there's a big difference between wrapper and margin.. :)
•
•
Join Date: Dec 2008
Posts: 64
Reputation:
Solved Threads: 13
•
•
•
•
Hello everyone....I've been working on the design for my forum on my website and while everything else has gone to plan...one thing hasn't. On my topic page,
Why is it XHTML, and why is it transitional?
•
•
•
•
the DIV with class greybox and id navigationbox
Why do you have:
You don't need both divs; the more complicated you make your mark-up, the harder it is to debug.HTML and CSS Syntax (Toggle Plain Text)
<div id="navigation"> <div id="nav-container"> ... </div> </div>
And within that (where I have put the ellipsis), you have:
HTML and CSS Syntax (Toggle Plain Text)
<div id="userbox" class="greybox"> <ul class="navlist"> <li><a href="#"><span>Login</span></a></li> <li><a href="#"><span>Register</span></a></li> </ul> </div>
You don't need both <div> and <ul>; use <ul> by itself.
And the <span>s are unnecessary.
•
•
•
•
that displays the text Home, New Posts, Members, Stats, Rules, etc. just wont align to the center of my 800px wrapper.
Why do you have an 800px wrapper? If my window is smaller than 800px, I can't see the whole thing and I have to scroll horizontally. If my window is larger, there are gutters on each side of the page.
Make it:
HTML and CSS Syntax (Toggle Plain Text)
width: 90%; margin: 0 auto;
and it will work for everyone.
•
•
•
•
I realize that it is set to float to the left and this is because for some reason when I don't float it to the left or right, the DIV's border does not display right in any browser (Well, I know it doesn't work in FF or Chrome, and I think it didn't it IE..).
If you float it left, of course it is not going to be centred!
•
•
•
•
When not floated the border doesn't surround the DIV and instead just stretches across the 800px wrapper. Can anyone help me figure out a way to fix this? (And preferably not a non-standard...I know I could use a table with three columns or add a div before it with width of 33.3%)
Thanks Everyone!
P.S. And while your at it..could you tell me how it looks? I'd love to hear some feedback before I actually start the server side of the forum.
It's very hard to read; there is not enough conrast between text and background.
Chris F.A. Johnson
http://cfajohnson.com
http://cfajohnson.com
You center something by applying the style:
margin: 0 auto;
or applying text-align: center to its containing element and text-align: left to the element.
Its fine for him to use an XHTML Transitional doctype, its just the "modern" version of HTML.
margin: 0 auto;
or applying text-align: center to its containing element and text-align: left to the element.
Its fine for him to use an XHTML Transitional doctype, its just the "modern" version of HTML.
92% of all statistics are made up on the spot.
If you found a post helpful, please click the "give XXX reputation" link, to show your appreciation to those who helped you. Thanks! :D
If you found a post helpful, please click the "give XXX reputation" link, to show your appreciation to those who helped you. Thanks! :D
Ok so I've fixed some of the problems with the nav lists and such, but there still are a few problems.
- The ul list with id navigationbox is still not aligning to the center. I have checked several times and it is not floated to the left or right. I have also tried
margin: 0 auto;andtext-align: center; - The divs that contain the post content with class post do not fill the area given to them. They won't stretch to fill the whole space between the side of the wrapper and the edge of the user details.
- Text Color/Contrast: cfajohnson suggested that the contrast of the white text on the gray background. I need some help deciding what color I should use for text. Here are my options (Or if you have a better idea please post it!!
):- The gray post boxes become a dark orange (#F60) with white text
- The gray post boxes become a dark orange (#F60) with black text
- The gray post boxes become a dark orange (#F60) with dark gray (#333) text
- Make all post text black
- Make all post text dark gray (#333)
Last edited by FlashCreations; May 24th, 2009 at 7:05 pm.
Have you tried using something like margin-left:25%;?
As for your post boxes how about black text on a light grey background? -maybe have a border slightly lighter or darker than the background.
As for your post boxes how about black text on a light grey background? -maybe have a border slightly lighter or darker than the background.
I don't mind helping but please mark your thread as solved once the problem is sorted. If you figure it out tell us how you did it, don't just abandon your thread!
I just tried the margin-left: 25% and sadly it didn't work. Maybe it's because I have my list set to display: inline-table so that the navlist displays right...no wait I tried it without any other properties and it still won't align center...this is wierd!!! Also I like your idea for the text. I was planning on using a black or really dark gray (just for some variety) text color, but do you think all the post text needs to be black or just the text inside the light gray boxes?
Also if anyone can figure out why this av box won't align center, I'd be grateful!!!
Also if anyone can figure out why this av box won't align center, I'd be grateful!!!
Last edited by FlashCreations; May 24th, 2009 at 11:40 pm.
Ok so I did fix the center align nav menu (It's still not perfect...640x480 people aren't going to like the look of it to much so if there is any other fix, please post!!
). Aside from that...any ideas on the post width problem not filling the whole given area?
). Aside from that...any ideas on the post width problem not filling the whole given area? •
•
•
•
Ok so I did fix the center align nav menu (It's still not perfect...640x480 people aren't going to like the look of it to much so if there is any other fix, please post!!). Aside from that...any ideas on the post width problem not filling the whole given area?
I would prefer the Nav to be longer and the text bigger. It would be much better if the navigation fit on one line.
I don't mind helping but please mark your thread as solved once the problem is sorted. If you figure it out tell us how you did it, don't just abandon your thread!
Here is my CSS for the navlist...
And the CSS looks like:
HTML Syntax (Toggle Plain Text)
<ul class="greybox navlist" id="navigationbox"> <li><a href="#"><span>Home</span></a></li> <li><a href="#"><span>New Posts</span></a></li> <li><a href="#"><span>Members</span></a></li> <li><a href="#"><span>Stats</span></a></li> <li><a href="#"><span>Rules</span></a></li> <li><a href="#"><span>FAQ</span></a></li> <li><a href="#"><span>Search</span></a></li> </ul>
And the CSS looks like:
CSS Syntax (Toggle Plain Text)
#navigation #navigationbox { margin: 0 33% 7px; } /* Note that the id navigation belongs to a div that this navlist is in */ /* 33% margin is experimental.....and breaks down with screen size 640x480 */ .greybox { background: #CCCCCC; border-bottom: 1px solid #999999; border-right: 1px solid #999999; color: #FFFFFF; margin-bottom: 5px; } ul.navlist { display: inline-table; height: 20px; margin-left: 25%; width: auto; } ul.navlist li { display: inline-table; height: 20px; list-style: none; margin: 0; padding: 0; } ul.navlist li a, ul.navlist li a:visited { background: #CCC; color: #FFF !important; height: 20px; padding: 0px 7px 5px 7px; text-decoration: none !important; } ul.navlist a:hover { background: #999999 !important; color: #FFF !important; text-decoration: none !important; } ul.navlist li a span { vertical-align: middle; } /* Note: The !important's are due to another part of the CSS document that define the color and background properties to be different (For another part of the site) */
You could try reducing the margin and set width to 100%.
If you are after a bit more space before Home and after Search try putting.
If you are after a bit more space before Home and after Search try putting.
<li> </li> // Your links <li>%nbsp</li>
I don't mind helping but please mark your thread as solved once the problem is sorted. If you figure it out tell us how you did it, don't just abandon your thread!
![]() |
Similar Threads
- How to set middle align for <div> without using padding (HTML and CSS)
- align a div to the bottom of another div (HTML and CSS)
- CSS Div help needed (HTML and CSS)
- Writing To div. Why wont this work? (JavaScript / DHTML / AJAX)
- DIV help (HTML and CSS)
Other Threads in the HTML and CSS Forum
- Previous Thread: How CSS Containers are control
- Next Thread: Need advice
| Thread Tools | Search this Thread |
Tag cloud for HTML and CSS
appointments asp background backgroundcolor beta browser bug calendar cart cgi code codeinjection corporateidentity create css design development displayimageinsteadofflash dreamweaver drupal emailmarketing epilepsy explorer firefox flash font fonts 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 perl pnginie6 positioning problem scroll seo shopping studio swf swf. templates textcolor theme timecolor titletags url urlseparatedwords visual visualization web webdevelopment webform website windows7 wordpress xml xsl





