views:

78

answers:

1

i have dynamic images from a database...i want to have a couple of images on top of each other..like a banner ad, when one image fades the other one displays...

When you click on the image it should redirect to a specific link

+3  A: 

This solution uses jQuery and the jQuery Cycle plugin. It basically runs it as a slide show, displaying one image at a time. The CSS puts a nice border around it, but you could eliminate that by adjusting the CSS. The cycle plugin has a number of options that you can use to adjust how the images transition.

<style>
.pics
{
    padding: 0;
    margin: 0;
    margin-left: 48px;
}

.pics img
{
    padding: 15px;
    border: 1px solid #ccc;
    background-color: #eee;
    top: 0;
    left: 0;
}
</style>
<script type="text/javascript">
    $(function() {
       $(window).load( function() { $(".pics").cycle() } );
    });
</script>

<div class="pics">
     <img alt="Banner Ad" onclick="location.href='/url/to/ad-site1.htm';" src="/url/to/img1.jpg" />
     <img alt="Banner Ad" onclick="location.href='/url/to/ad-site2.htm';" src="/url/to/img2.jpg" style="display: none;" />

     <img alt="Banner Ad" onclick="location.href='/url/to/ad-site3.htm';" src="/url/to/img3.jpg" style="display: none;" />
</div>
tvanfosson