Do you want to be a good Web Developer?

Enter Your Email To Get Our Exclusive Tutorials
And Offer Right In Your Email

Join TalkersCode Community And Recieve Exclusive Tutorials
On Web Development Right Via Email.

Slide Text On Images Using jQuery

Thursday, Jan 12, 2017

Tags:- CSS jQuery


In this tutorial we will show you how to slide text on images using jQuery and CSS.It looks nice and also saves space for more writing, whenever user hover on image a text appear from bottom to top with sliding effect.You may also like display text over image using HTML and CSS.


See Demo
Slide Text On Images Using jQuery


To Slide Text On Image It Takes Only Two Steps:-

  1. Make a HTML file and define markup and scripting
  2. Make a CSS file and define styling


Step 1.Make a HTML file and define markup and scripting

We make a HTML file and save it with a name slide.html

<html>
<head>
 <link href="slide.css"  rel="stylesheet" type="text/css"/>
 <script type="text/javascript" src="js/jquery.js"></script>
 <script>
  $(document).ready(function() 
  {
   $('.text_conainer').hover(function()
   {
    $('.text_div').slideToggle('slow');
   },
   function()
   {
    $('.text_div').slideToggle('slow');
   });
  });
 </script>

</head>
<body>
<div id="wrapper">
 <div class="text_conainer">
  <img src="image1.jpg"/>
  <div class="text_div">
   <h2>TalkersCode.com</h2>
   <p>Demo Of Sliding Text On Image</p>
  </div>
 </div>
</div>
</body>
</html>

In this step we create a div to hold image and text and we use jQuery slideToggle() function to slide the text up and down on hover.You may also like add text on image using PHP.



Step 2.Make a CSS file and define styling

We make a CSS file and save it with a name slide.css

body
{
 text-align:center;
 width:100%;
 margin:0 auto;
 padding:0px;
 font-family:helvetica;
 background-color:#086A87;
}
#wrapper
{
 text-align:center;
 margin:0 auto;
 padding:0px;
 width:995px;
}
.text_conainer 
{
 width:400px;
 height:300px;
 position: relative;
 margin: 5px;
 margin-left:300px;
 color: #333;
}
.text_conainer img
{
 height:300px;
 width:400px;
}
.text_conainer .text_div 
{
 display: none;
 opacity: 0.8;
 background:#58ACFA;
 width: 400px;
 position: absolute;
 bottom: 0px;
 padding: 5px;
 box-sizing:border-box;
 text-align:center;
 color:white;
}

In this step we make our 'text_conainer' relative and 'text_div' absolute remember this without using these positions the text will never slide over image.You may also like add watermark on image using PHP.


Thats all, this is how to slide text on images using jQuery.You can customize this code further as per your requirement. And please feel free to give comments on this tutorial.

Join Us With Our 21000+ Subscribers And Get Our Latest Tutorials Update Via Email