unordered list background image


something very simple i am trying to achieve but it looks harder than i thought.....

in an unordered list (with a link inside it) i am trying to aligned the background image (which is an arrow) to the right with a little bit of left padding so it will not be so close to the link.
the link can be at any length so i am not able to fix the width of the <li> nor the <a>.
the background image or goes way to the right or when using left position and paddings the arrow background image get cut due to the font size.

attached a screenshot of what i am trying to archive. again the link text can be at any length.

 screenshot
Thanks!!!
RefaelAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

bill30Commented:
a few solutions:

after the text type &nbsp;
&nbsp; is the http command for a space and it could give you the space you want, you can use it several times &nbsp;&nbsp;
ex: <ul>
<li><a href="#">THIS IS THE LINK TEXT</a>&nbsp;&nbsp;</li>
</ul>

or photoshop the image and add extra white pixels to the left of it until you have the spacing you need
hankknightCommented:
Here is an image to use:
link.png
hankknightCommented:
And here is the code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<title>Demo</title>
<style type="text/css">
html,body {
background:#fff;
}

ul {
list-style: none;
margin: 0;
padding: 0;
}

li {
background: transparent url(http://filedb.experts-exchange.com/incoming/2011/04_w15/440692/link.png) no-repeat scroll 100% 100%;
height: 34px;
line-height: 34px;
padding: 2px 1px 0 1px;
margin: 0;
width: 200px;
}

li a, li a:link, li a:visited {
font-family: "arial narrow", "helvetica narrow", arial, helvetica, "san serif";
font-size: 18px;
font-weight: 600;
color: #2C3F5F;
height: 34px;
line-height: 34px;
text-decoration: none;
display: block;
}

li a:hover {
color: red;
}

</style>
</head>
<body>

<h1>Hello World</h1>

<div>
 <ul>
  <li><a href="#">Link 1</a></li>
  <li><a href="#">Link 2</a></li>
  <li><a href="#">Link 3</a></li>
  <li><a href="#">Another Link Example</a></li>
 </ul>
</div>

</body>
</html>

Open in new window

Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

RefaelAuthor Commented:

hankknight, thanks for the example
the problem is you set the width to 200px. Some links text are shorter and some are longer.
hankknightCommented:
Then change display to block for the links, like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<title>Demo</title>
<style type="text/css">
html,body {
background:#fff;
}

ul {
list-style: none;
margin: 0;
padding: 0;
}

li {
height: 34px;
margin: 0;
padding: 0;
}

li a, li a:link, li a:visited {
background: transparent url(http://filedb.experts-exchange.com/incoming/2011/04_w15/440692/link.png) no-repeat scroll 100% 50%;
font-family: "arial narrow", "helvetica narrow", arial, helvetica, "san serif";
font-size: 18px;
font-weight: 600;
color: #2C3F5F;
height: 30px;
line-height: 30px;
text-decoration: none;
display: inline;
padding: 2px 35px 2px 1px;
}

li a:hover {
color: red;
}

</style>
</head>
<body>

<h1>Hello World</h1>

<div>
 <ul>
  <li><a href="#">Link 1</a></li>
  <li><a href="#">Link 2</a></li>
  <li><a href="#">Link 3</a></li>
  <li><a href="#">Another Link Example</a></li>
 </ul>
</div>

</body>
</html>

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RefaelAuthor Commented:

so after spending hours, here is the solution. compatible in IE 7 and 8 as well:
ul {
	margin:0;
	padding:0;
	margin-top:10px;
	list-style:none;
}
li {
	padding:0;
	height:29px;
	line-height:28px;
	font-family:Helvetica, Arial, sans-serif;		
}
li span {
	display:inline-block;
	width:21px;
	float:left;
	background: transparent url(../layout/more_arrow.png) no-repeat scroll 100% 100%;
	height:25px;
	line-height:32px;
	padding: 0px 10px 0px 0px;
}
li a {
	float:left;
	font-size:12px;
        font-weight: 600;
        color: #2C3F5F;
	height: 20px;
        line-height: 28px;
	text-decoration:none;
        border-bottom:2px #900 solid;
	letter-spacing:1px;
        text-transform:uppercase;
}



<li><a href="#">THE LINK TEXT</a><span></span></li>

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
CSS

From novice to tech pro — start learning today.