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.
CHECK OUT THIS TUTORIAL LIVE DEMO →
To Slide Text On Image It Takes Only Two Steps:-
- Make a HTML file and define markup and scripting
- 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.
Latest Tutorials
- Create Animated Skill Bar Using jQuery, HTML And CSS
- Simple And Best Responsive Web Design Using CSS Part 2
- Show Button On Hover Using HTML And CSS
- Material Design Login Form Using jQuery And CSS
- Animated Progress Bar Using jQuery And CSS
- Dynamic Drop Down Menu Using jQuery, Ajax, PHP And MySQL
- Get Website Statistics Using PHP, jQuery And MySQL
- HTML5 Login And Signup Form With Animation Using jQuery
- Facebook Style Homepage Design Using HTML And CSS
- View Webpage In Fullscreen Using jQuery