tags:

views:

1009

answers:

4

I'm using a background image for a <li> that will be used as a button, but it's not fully shown; however, when write text then it shows. I don't want text to be written it's already printed on background image. I am unable to set a width - how can I fix this?

#footernav li#footerlocation
{
    display: inline;
    padding-right: 20px;
    background-image: url(../images/ourlocation.jpg);
    background-repeat: no-repeat;
    background-position: 0 -.2em;
}
+2  A: 

Your problem is in setting display to inline. If you want background and width, but you also need an inline-type list, set float: left.

bigmattyh
Thanks, but somewhere i saw they indent the text to thousand pixel to disappear, anyway i follow ur sugestion and its working now.
Yasir
You can still indent the text -- that actually has nothing to do with the layout. The problem is that when you set display to inline on a block-level element, it will naturally shrink to the minimum width required; so if an element has no text, the width goes to zero.
bigmattyh
A: 

set the width and height for the image

Sruly
+2  A: 

Take a look at the following example:

   ul#footernav li { 
        display:inline; 
        }
    ul#footernav li a{ 
        display:block; 
        width:155px;
        text-indent:-9999px;
        }
    ul#footernav li.footerlocation a{ 
        height:30px ; 
        background: url('images/image.jpg') bottom left no-repeat; 
        }
    ul#footernav li.footerlocation a:hover{ 
        height:30px ; 
        background: url(images/image.jpg) top left no-repeat; 
        }
superUntitled
Thanks SuperUnititled that's what i want to do that time, next time will must use this.
Yasir
A: 

Yes i have the same problem, i just removed css style display: inline and add display: list-item; float:left; my problem solved, hope this helps.

Thanks, Sankar B