Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-21-2005, 07:10 PM   PM User | #1
kraftomatic
Regular Coder

 
Join Date: Jul 2003
Posts: 593
Thanks: 16
Thanked 0 Times in 0 Posts
kraftomatic is an unknown quantity at this point
Help: Using Images For Lists via CSS

Hey Guys,

I've got the following CSS that works great:

.rowTwoLeftText ul li {
background: url(images/arrow2.gif) no-repeat 70px 11px;
margin: 0 0 0 -10px;
padding: 8px 0 0 0;
display: block;
color: #666;
/*border: 1px solid #000;*/
}

It displays correctly in a listing like this:

<div class="rowTwoLeftText">
<ul>
<li>dada</li>
</ul>

However, the problem I'm running into is that it only displays correctly with a fixed length of text within the LI tag ( as shown by the hardcoded location in the CSS).

How can I make the arrow.gif move, depending on the length of the text? I know this has to be possible, but I've been racking my brain and cannot get it to work.

Any help would be much appreciated.

Thanks.
kraftomatic is offline   Reply With Quote
Old 12-21-2005, 07:31 PM   PM User | #2
SpirtOfGrandeur
Regular Coder

 
Join Date: May 2005
Location: Michigan, USA
Posts: 566
Thanks: 0
Thanked 0 Times in 0 Posts
SpirtOfGrandeur is an unknown quantity at this point
background: url(images/arrow2.gif) no-repeat right middle;
__________________
Note: I do not test code. I just write it off the top of my head. There might be bugs in it! But if any thing I gave you the overall theory of what you need to accomplish. Also there are plenty of other ways to accomplish this same thing. I just gave one example of it. Other ways might be faster and more efficient.
SpirtOfGrandeur is offline   Reply With Quote
Old 12-21-2005, 07:38 PM   PM User | #3
kraftomatic
Regular Coder

 
Join Date: Jul 2003
Posts: 593
Thanks: 16
Thanked 0 Times in 0 Posts
kraftomatic is an unknown quantity at this point
Seems close .. using your code, the image disappears (out of the DIV tag I'm guessing).

If I remove "middle" and keep it to the right, it will expand and space itself out of the text grows, however it stays on the right end of the DIV box if the text is shorter.

Any ideas?
kraftomatic is offline   Reply With Quote
Old 12-21-2005, 07:53 PM   PM User | #4
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
Lets see, you ask a question about a background image yet you don't tell us where this image is. Umm its not like we know what it looks like either. Post a link or attach the image.
_Aerospace_Eng_ is offline   Reply With Quote
Old 12-21-2005, 07:54 PM   PM User | #5
kraftomatic
Regular Coder

 
Join Date: Jul 2003
Posts: 593
Thanks: 16
Thanked 0 Times in 0 Posts
kraftomatic is an unknown quantity at this point
Quote:
Originally Posted by _Aerospace_Eng_
Lets see, you ask a question about a background image yet you don't tell us where this image is. Umm its not like we know what it looks like either. Post a link or attach the image.
The image is irrelevant, but for sake of example, it's a small arrow. It sits just to the right of the linking/list text.
kraftomatic is offline   Reply With Quote
Old 12-21-2005, 08:09 PM   PM User | #6
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
Try spirit's code but instead of right middle try right center
_Aerospace_Eng_ is offline   Reply With Quote
Old 12-21-2005, 08:18 PM   PM User | #7
kraftomatic
Regular Coder

 
Join Date: Jul 2003
Posts: 593
Thanks: 16
Thanked 0 Times in 0 Posts
kraftomatic is an unknown quantity at this point
Quote:
Originally Posted by _Aerospace_Eng_
Try spirit's code but instead of right middle try right center
No dice ..
kraftomatic is offline   Reply With Quote
Old 12-21-2005, 08:31 PM   PM User | #8
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
Attach the image you are using. Some of us help better when we see things visually. You may think its irrelevant but I don't think it is.
_Aerospace_Eng_ is offline   Reply With Quote
Old 12-21-2005, 08:43 PM   PM User | #9
kraftomatic
Regular Coder

 
Join Date: Jul 2003
Posts: 593
Thanks: 16
Thanked 0 Times in 0 Posts
kraftomatic is an unknown quantity at this point
Quote:
Originally Posted by _Aerospace_Eng_
Attach the image you are using. Some of us help better when we see things visually. You may think its irrelevant but I don't think it is.
Attached here. Thanks.
Attached Images
 
kraftomatic is offline   Reply With Quote
Old 12-21-2005, 08:51 PM   PM User | #10
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
Short of putting the image tag inside of the li, CSS can't adjust the background image dynamically.
_Aerospace_Eng_ is offline   Reply With Quote
Old 12-21-2005, 09:06 PM   PM User | #11
kraftomatic
Regular Coder

 
Join Date: Jul 2003
Posts: 593
Thanks: 16
Thanked 0 Times in 0 Posts
kraftomatic is an unknown quantity at this point
Quote:
Originally Posted by _Aerospace_Eng_
Short of putting the image tag inside of the li, CSS can't adjust the background image dynamically.
That's the answer I was looking to confirm, thanks.
kraftomatic is offline   Reply With Quote
Old 12-21-2005, 09:13 PM   PM User | #12
circusbred
Regular Coder

 
Join Date: Apr 2004
Location: Birmingham, MI
Posts: 131
Thanks: 0
Thanked 0 Times in 0 Posts
circusbred is on a distinguished road
Sure you can!! Put the text into an inline element such as <a> or <span> then apply a right padding to the element. Example:
Code:
<style type="text/css">
   ul li a { padding-right:10px; background:url(arrow2.gif) right center no-repeat; }
</style>
HTML:
Code:
<ul>
   <li><a href="#">Some Test</a></li>
   <li><a href="#">Tests test stest </a></li>
   <li><a href="#">tests</a></li>
   <li><a href="#">t</a></li>
</ul>
EDIT: PS its "CENTER" not 'middle' for background-position.
circusbred is offline   Reply With Quote
Old 12-21-2005, 09:16 PM   PM User | #13
kraftomatic
Regular Coder

 
Join Date: Jul 2003
Posts: 593
Thanks: 16
Thanked 0 Times in 0 Posts
kraftomatic is an unknown quantity at this point
I coulda swore I tried that .. but it appears to work .. h mm ..
kraftomatic is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:34 AM.


Advertisement
Log in to turn off these ads.