Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nivo slider - add text to the slider

I am currently using the nivo slider on my homepage, to show different images. It works perfectly. Although, next to the images there are some text, which I would like to follow each picture.

Here is the HTML code:

     <!-- Splash -->
            <div class="splash">
              <div class="splash-content">
<div id="text1">                
<h1>More traffic to your website</h1>
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elitectetur adipis. In ultrices malesuada est eu laoreet. Nullam eget tellus ac lacus bibendum egestas et at libero. Vestibulum commodo magna ut suscipit.</p>
</div>                
              </div>

            <div id="slider" class="nivoSlider nivo-right theme-default">
                <img src="images/splash.png" alt="" title="" />
                <img src="images/splash.png" alt="" title="" />
                <img src="images/splash.png" alt="" title="" />
                <img src="images/splash.png" alt="" title="" />

            </div>


        </div><!-- End Splash -->

As you can see in the HTML code, there is the <div id="slider">, which is the nivo slider. Although, I wish to have the <div id="text1"> to follow each picture. Then have a <div id="#text2"> to follow the next image and so on.

The jQuery code to control the nivo slider:

<script type="text/javascript">
$(window).load(function() {
    $('#slider').nivoSlider({
        effect: 'sliceUp', // Specify sets like: 'fold,fade,sliceDown'
    });
});
</script> 

Thanks in advance.

like image 336
oliverbj Avatar asked Mar 16 '12 07:03

oliverbj


People also ask

What is Nivo Slider?

The Nivo is a jQuery slider that is quite popular in the market and an easy to use plug-in that you may deploy in your website freely. The plug-in can be downloaded from the developer's page at Github website which JS file size is only 30Kb.


3 Answers

Use title attribute in the <img /> to define text to appear as caption in the slider.


Lets see an example:

<div id="slider" class="nivoSlider">
    <img src="images/slide1.jpg" alt="" />
    <img src="images/slide2.jpg" alt="" title="#htmlcaption" />
                                             <!-- ^ This is one way to bring caption -->
    <img src="images/slide3.jpg" alt="" title="This is an example of a caption" />
                                             <!-- ^ This is ANOTHER way -->
</div>

<!-- This part of caption is called from the second image link above see  `#htmlcaption` there -->
<div id="htmlcaption" class="nivo-html-caption">
    <strong>This</strong> is an example of a <em>HTML</em> caption with <a href="#">a link</a>.
</div>

Update

Without hacking the code, you can override the default class to appear as a separate text box.

Find .nivo-caption style and make some changes to it

.nivo-caption { 
       width: 200px; 
       height: 250px; 
       left: -200px; /* same as the width */
 }

Update 2

Here is a demo with your slider working with the workaround i mentioned.

SO far as this question goes, this is where i stop. Hope it helps.

like image 65
Starx Avatar answered Oct 22 '22 17:10

Starx


<div id="slider" class="nivoSlider">
 <div class="slide slide_0">
   <img class="slide-image" src='img1.png' width="100%"  title="#htmlcaption_0">
 </div>
 <div class="slide slide_1">
   <img class="slide-image" src='img2.png' width="100%"  title="#htmlcaption_1">
 </div>
 <div class="slide slide_2">
   <img class="slide-image" src='img3.png' width="100%"  title="#htmlcaption_2">
 </div>
</div>

<div id="htmlcaption_0" class="nivo-html-caption">
 <h1 class="slide-h1">Title</h1>
 <h2 class="slide-h2">Description</h2>
 <h3 class="slide-h3">
   <a href="#" title="">Learn More &raquo;</a>
 </h3>
</div>
<div id="htmlcaption_1" class="nivo-html-caption">
 <h1 class="slide-h1">Title</h1>
 <h2 class="slide-h2">Description</h2>
 <h3 class="slide-h3">
   <a href="#" title="">Learn More &raquo;</a>
 </h3>
</div>
<div id="htmlcaption_2" class="nivo-html-caption">
 <h1 class="slide-h1">Title</h1>
 <h2 class="slide-h2">Description</h2>
 <h3 class="slide-h3">
   <a href="#" title="">Learn More &raquo;</a>
 </h3>
</div>

Here's my css:

.nivo-caption {
  color: #FFFFFF;
  min-width: 550px;
  overflow: hidden;
  position: absolute;
  top: 180px;
  z-index: 8;
}

.nivo-html-caption {
  display:none;
}

Hope this helps.

like image 23
Abhilash Shamsunder Avatar answered Oct 22 '22 17:10

Abhilash Shamsunder


See this demo, they have captions.

like image 36
Riz Avatar answered Oct 22 '22 18:10

Riz