views:

131

answers:

2

This question seems to be asked freqeuently over the internet but I still can't find a solution.

I have this navigation bar (It switches between tabs using jQuery) which displays inline. I'm showing a background image on these and to make them more definitive I need to make them wider and higher.

<div id="tabs">
<ul id="tabs-nav-cont">
    <li class="tabs-navs"><a href="#tabs-1">Nav 1</div></a></li>
    <li class="tabs-navs"><a href="#tabs-2">Nav 2</div></a></li>
    <li class="tabs-navs"><a href="#tabs-3">Nav 3</div></a></li>
    <li class="tabs-navs"><a href="#tabs-4">Nav 4</a></li>
</ul>
</div>

The only way I can seem to do this is by reverting them back to block elements. Which is not what I want because they display vertically. So I tried putting divs in the anchors so I can size them up. However they seem to change them back to block elements too.

Im confused. Someone please help :)

+3  A: 

Luckily you live in the year 2009, where inline-block is widely adopted through browsers: Cross browser inline-block.

If it's just for the height (and all the content of the lis fits each on one line), you'd like to go with line-height: 123px, which sets the height of an inline box to 123px (per line, that is).

Or, quite common, if the navigation is left-aligned, float them:

#nav li {
  display: block;
  float: left;
}

Cheers,

Boldewyn
Well thank god for 2009. I had no idea that inline-block existed. Thank you!
Ben Shelock
I was busy making a demo, while you answered. :) http://jsbin.com/eraga
Stobor
;-) @Ben: You're welcome. @Stobor: I visited the link just last week again, so it was kind of reachable in my browser history.
Boldewyn
A: 

Because it was not 2009 when i first had to solve this :) i got the solution for firefox with following css class:

.ib { display: -moz-inline-block; display: inline-block;}

This is my generic inline-block class that i use where necessary...

Sinan.

Sinan Y.