0

I am trying to display the previous and next buttons, but as I compile it it just give me the link saying 'previous' and 'next' instead of the image I want. Below here I am showing first the code in CSS;

div#slideshow ul#nav li#prev a
{
    background: url(Resources/Icons/previous.png);
}

div#slideshow ul#nav li#next a
{
    background: url(Resources/Icons/next.png);
}

Then here I am showing how I am calling it from asp;

<div id="slideshow">
    <ul id="nav">
        <li id="prev"><a href="#">Previous</a></li>
        <li id="next"><a href="#">Next</a></li>
    </ul>
</div>

Any suggestions of what the problem could be?

Evan Mulawski
  • 54,662
  • 15
  • 117
  • 144
IT_info
  • 707
  • 4
  • 16
  • 36

6 Answers6

1

Using:

<a href="#">Previous</a>

... will give you a hyperlink with "Previous" as the text. Your CSS might add a background to the list item, but you will still only end up with a hyperlink.

Examples of alternatives:

<input type="image" src="/path/to/image.gif" />

<a href="GoHere.html"><img src="/path/to/image.gif" alt="My Image" /></a>

<img src="/path/to/image.gif" alt="My Image" onclick="SomeJavaScript();" />
Adrian Thompson Phillips
  • 6,893
  • 6
  • 38
  • 69
0

Your markup is valid in the sense that an image would appear behind the innerHTML of the <a></a>.

Problem is most likely an issue with the path to the PNG - try putting the png in the same folder as the html file and using url(next.png)

HeavenCore
  • 7,533
  • 6
  • 47
  • 62
0

Ensure CSS file paths are relative to the CSS file, not the HTML page.

Simon West
  • 3,708
  • 1
  • 26
  • 28
0

The url path you are passing in is relative to the location of the stylesheet. So if your style sheet is found at /styles/css/themes.css then the background image here will be looked for at /styles/css/Resources/Icons/XXX.png. Is that where they are being stored?

Andy Rose
  • 16,770
  • 7
  • 43
  • 49
0

you are using an anti-pattern Be Specific when Needed

use the following instead. #prev a { ... }

#next a {
           ...
        }​
Mike Lin
  • 370
  • 1
  • 9
0

You should not be setting the background of a tag as it is an inline element.

You should instead insert an inner element and set the style of it to accomondate your image display.

<div id="slideshow">         
<ul id="nav">             
    <li id="prev"><a href="#" title="prev"><div></div></a></li>             
    <li id="next"><a href="#" title="next"><div></div></a></li>         
</ul> 

​ Also as you have given your a tags ids you can shorten your css definition considerably by specifying them directly.

#prev a div
{             
background: url(http://images.all-free-  download.com/images/graphicmedium/button_previous_89678.jpg);
height : 200px;
width : 200px;       
} 


#next a div
{             
background: url(http://images.all-free-download.com/images/graphicmedium/button_next_89675.jpg);
height : 200px;
width : 200px;            
} ​

See this fiddle for a working example

Nicholas Murray
  • 13,305
  • 14
  • 65
  • 84