views:

1348

answers:

6

Hey,

I was using jQuery plugins to create a rounded corner for my

< li >

but it was not working on alot of browsers and didnt support mouse over, it acted very strange.

I am wondering what is the best way to use two images (left corner and right corner) as the left and right side with using < li >

Any thoughts? I looked on google and here, but it only brought up more jQuery plugins, and rounded corners using < div > elements for content.

Ryan

A: 

You could put Divs inside your li's like so:

<li>
  <div class="lefcorner"></div>
  <div class='liContent'>Foo</div>
  <div class='rightcorner'></div>
</li>

That way you will both keep your semantics and will also have the cross-browser support of styling DIVs.

Pim Jager
I think it might be invalid to put a div inside of an li, depends on whether you care about that or not.
seanb
It's not how I would do it, but it's not invalid. LIs can take both inline and block-level content.
mercator
According to the W3C HTML validator it's okay in HTML 4.01 loose
Pim Jager
A: 

Let me give this a go :) Ill post my results.

Coughlin
A: 

For the left and right corners, I would just have to set the width to the width of the background image correct?

Coughlin
pretty much, you could also use the rounded corners on the liContent DIV and remove the other two corner divs since you won't use them if you use the plugin.
Pim Jager
A: 

The construct that I have seen used most for that is a span inside a link.

so something like:

<li><a><span>Your text here</span></a></li>

you can then target the span and the link using the hover state of the link:

a:hover{some rules here}  
a:hover span{some more rules here}

that keeps it kinda semantic, and doesn't add to much junk to the page.

seanb
A: 

Hey, below is my current code, but wont display the background unless I make it display:block. But if I do that it wont make my list inline as i want it, ideas?

#top ul li.corner span.left-corner{
    background-image:url("images/corner-left.gif");
    background-repeat:no-repeat;
    width:12px;
    height:23px;
}
#top ul li.corner span.right-corner{
    background-image:url("images/corner-right.gif");
    width:12px;
    height:23px;
}
#top ul li.corner span.content{
    background-color:#2C2C2C;
    width:12px;
    height:23px;
}

HTML:

<ul>
 <li class="corner">
  <span class="left-corner"></span>
  <span class="content"><a href="http://www.ryancoughlin.com/index.php" title="Go Home">home</a></span>
  <span class="right-corner"></span>
 </li>
 <li class="corner">
  <span class="left-corner"></span>
  <span class="content"><a href="category/tutorials/" title="View Tutorials">tutorials</a></span>
  <span class="right-corner"></span>
 </li>
 <li class="corner">
  <span class="left-corner"></span>
  <span class="content"><a href="category/blog/" title="Read My Blog">blog</a></span>
  <span class="right-corner"></span>
 </li>
 <li class="corner">
  <span class="left-corner"></span>
  <span class="content"><a href="about/" title="Get To Know Me">get to know me</a></span>
  <span class="right-corner"></span>
 </li>
 <li class="corner">
  <span class="left-corner"></span>
  <span class="content"><a href="category/blog/" title="Read My Blog">blog</a></span>
  <span class="right-corner"></span>
 </li>
 <li class="corner">
  <span class="left-corner"></span>
  <span class="content"><a href="contact/" title="Contact Me">coffee? chat? project?</a></span>
  <span class="right-corner"></span>
 </li>
 <li class="corner">
  <span class="left-corner"></span>
  <span class="content"><a href="http://feeds.feedburner.com/ryancoughlin/" title="Subscribe">subscribe</a></span>
  <span class="right-corner"></span>
 </li>
</ul>
Coughlin
couldn't You use display:block and float them?
Pim Jager
I did that...thank you Pim!Ryan
Coughlin
A: 

I got the answer. Pim wrote in the comment to my reply above, to float the li's and set display:block.

Working great!

Coughlin