tags:

views:

1580

answers:

4

I'm trying to create a layout that looks like a LI with a bullet, but that doesn't use a LI. I can't use a LI because I want to allow different items in the same list to have different bullet images. And from what I can tell LI bullet styles can only be set in the UL, so all LI in the same UL must have the same bullet image... and I don't want that. Please correct me if I am wrong about how LI's can be styled.

Here's the HTML that I'm trying to style so that it recreates a LI bullet.

<div><img src="..."/><p>Inbox:</p></div>

I'm not sure how best to achieve the following goals:

  • Make bullet image display to the left of the item text box so that when there is lots of text the bullet hangs off in the left margin. The text shouldn't wrap under the bullet image.
  • Keep the bullet image aligned middle with the first line of text (in the case of text wrapping). And keep the bullet middle aligned when the text changes size.

My high level goal is to recreate TaskPaper's UI in a web page:

I'll be happy to give a free license to the person with the solution that I like best.

Thanks,

Jesse

A: 

you could use span as alternative

<span><img src="">text</img></span>

or you could use default ul but with different images for each li

<ul>
<li><img src="image1">text1</img></li>
<li><img src="image2">text2</img></li>
</ul>

then align the margin of each image on li using css

li img{margin-left: 5px}

yeah something like that

Dels
+3  A: 

You can use CSS classes to do that:

<HTML>
  <HEAD>
    <STYLE>
      LI.circle { list-style: circle }
      LI.square { list-style: square }
    </STYLE>
  </HEAD>
  <BODY>
    <UL>
      <LI class="circle">Circle</LI>
      <LI class="square">Square</LI>
      <LI>Third</LI>
  </BODY>       
</HTML>

And if you need an arbitrary image, go like LI.whatever { list-style: url(myimage.png) }

GreenReign
http://jsbin.com/exopu as an example.
Stobor
Well I'm an idiot... but thank you :) CSS isn't my normal skill set, and I guess it shows. If you want a license to TaskPaper (a Mac app) please email me jesse at hogbaysoftware com.
Jesse Grosjean
I believe IE has problems with the above - if this is the case use the image replace method someone posted below.
Meep3D
A: 
<ul>
<li style="list-style:disc;">Foo</li>
<li style="list-style:square;">Bar</li>

tsmango
+1  A: 

You also can use list-style-type: none; and then use background image

DroidIn.net