tags:

views:

344

answers:

3

I have nav a bar on my site but I want to put rounded corners on each end of it. So far my css for this is..

#nav {
left:40px;
position:relative;
top:140px;
}
#nav a {
background-image:url(../images/menu.png);
background-repeat:no-repeat;
color:#FFFFFF;
display:inline;
float:left;
font-family:Arial,Helvetica,sans-serif;
font-size:17px;
font-weight:bolder;
height:44px;
padding-top:12px;
text-align:center;
text-decoration:none;
width:134px;
}
#nav a:hover {
background-image:url(../images/menu_ro.png);
background-repeat:no-repeat;
}

and my HTML..

<div id="nav">
<a href="">Home</a>
<a href="">Food</a>
<a href=""</a>
<a href=""</a>
<a href=""</a>
<a href=""></a>
<a href=""</a>
</div>

I have rounded corners to put on each end called menu_l.png and menu_r.png. Can't quite figure out how to put these on either end of the nav. My attempts so far seem to be getting ignored by browsers. Anyone have a best method to achieve this? Im trying to avoid tables.

Cheers

A: 

The easy way to do this in some modern browsers is to add something like:

-moz-border-radius: 8px; -webkit-border-radius: 8px;

which will handle mozilla-based and safari-like (webkit-based) browsers.

Alas, IE is more complicated.

Peter
If you're going with this, you might want to add `border-radius: 8px;`. Even though it's not supported by any browser yet, it probably will down the line, and you might as well add it now.
peirix
Surely that would work in IE6? lol. I think I might have to stick with something a bit more traditional. Thanks Peter
A: 

You could set the left background on the first link and the right background on the #nav element.

You could also set the left bg on the #nav and the right on the #nav by using the content selector ::after.

Philipe Fatio
+1  A: 

Try adding a div at the beginning of #nav, and at the end.

<div id="nav">
  <div id="nav-left"></div>
  //anchor tags
  <div id="nav-right"></div>
</div>

then do this for CSS: (assuming your rounded corner image is 15px wide)

#nav {
   padding: 0 15px;
}
#nav-left, #nav-right {
   float: left;
   height: 15px;
   width: 15px;
}

Then apply rounded corner image.

peirix
I did try this but it did not work hence my post. Left and right side images are different.
What isn't working? And you can apply different styles to each side if the images are different.
peirix
Thanks peirix adapted your code a bit.#nav {position:relative;top:140px;padding:0px;}#nav-left {background-image:url(../images/menu_l.png);background-repeat:no-repeat; float: left; height: 44px; width: 11px;}#nav-right {background-image:url(../images/menu_r.png);background-repeat:no-repeat; float: left; height: 44px; width: 11px;}
urrrr, that didn't come out right but rest assured it works. Thanks