views:

195

answers:

3

Hi everyone. I'm having hard time with Xhtml Strict 1.0 and Css. And I'm almost out of solutions.

My Site Url: http://www.pro-turk.net/beta/

I made a jquery multilevel dropdown menu for my site.

It looks like OK, but I have used inline-block property of css display attribute on navigation menu which is a part of css 2.1 and isn't supported by some browsers (including ie6 and ie7).

I want to make #nav > li elements block level elements, but to do this and having all of them in same line, the only way is using float in #nav > li. But I want to center them in their parent (the menu bar). So I need something like float:center (I know it's pretty stupid and doesn't exist). But is there a way to include block level elements as children elements without linebreaks (I mean without making a block level element).

Regards.

A: 

You can make li float left or right and make the menu itself centered. Make the menu the width of the sum of its elements.

#nav
{
    width: 500px;

    /* This will center the block within its container */
    margin-left: auto;
    margin-right: auto;
}

EDIT: Since you don't know the width of the menu (it's dynamic) we're coming to the very case when there is no alternative to tables.

<table border="0" cellpadding="0" cellspacing="0" style="margin: 0 auto;">
    <tr>
        <td>Menu item 1</td>
        <td>Menu item 2</td>
        <td>Menu item 3</td>
    <tr>
<table>

P.S. There is some substitution for tables with newer CSS3 extensions like display:table | table-cell etc., but it doesn't have a wide-spread support yet.

Developer Art
That doesn't work.<ul> is a block level element which fills the entire line.If I make #nav > li float it just floats to left(or right) in that line.Btw I can't give a fixed width to <ul> because menu is changing depending on if user is logged etc.
Axel Myers
I saw you edit but as I said in my note*I can't give a fixed width to #nav because menu is changing depending on if user is logged/user is admin,mod etc.
Axel Myers
It's actually quite doable without actual table elements by using display: table; for real browsers and a particularly nasty hack for IE.
Matti Virkkunen
Is there any hack or something for Ie? My site doesn't support below IE8 because they don't support inline-block.If I should use tables to design, why do I use Xhtml.Btw I tried to trigger hasLayout of ie7 but still very buggy.Maybe I should just use tables...
Axel Myers
A: 

I think there is no solution for it in css2 without using tables.

Axel Myers
A: 

display:inline-block isn't supported in IE6 or IE7, but you can get the same effect in those browsers by using display:inline and ensuring that hasLayout is set on those element by, say, using zoom:1. Use conditional comments to direct the different css to those browsers only.

Alohci
I already did this, but it doesn't work properly.
Axel Myers
Can you be more specific? In what way did it not work?
Alohci