When you’d like to show your visitors a larger version of an image on your website, what you would usually do is provide a link that will open up another tab or window that will contain the high resolution image. And while that may be the simplest way of handling it, some still don’t like the idea of diverting the viewer’s attention from the page.
That’s where this nice little jQuery trick comes in courtesy of Shiv Chawla of tipsntrack. Once you have this done on your Blogger blog, whenever someone hovers their mouse cursor over the image, a separate box will appear within the current page and show the image which is zoomed (only the specific part where the mouse hovers is zoomed).
Here’s how you can implement it on your blog:
- From you Blogger dashboard, go to Template.
- Click on Edit HTML and then on Proceed.
- Place a check inside the Expand Widgets Template box.
- By using Ctrl+F, search for the </head> tag and then copy/paste the following code right above and before it.
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js' type='text/javascript'/> <script src='http://js.howtouses.com/blogger/easyzoom.js' type='text/javascript'/> <script type='text/javascript'> $().ready(function() { $('a.zoom').each(function(i) { $(this).easyZoom(); }); }); </script>
- Next, using Ctrl+F again, look for ]]></b:skin> and then copy/paste the following code shown above and before it:
#easy_zoom{ width:500px; height:400px; border:5px solid #eee; background:#fff; color:#333; position:fixed; top:35px; left:50%; overflow:hidden; -moz-box-shadow:0 0 10px #555; -webkit-box-shadow:0 0 10px #555; box-shadow:0 0 10px #555; /* vertical and horizontal alignment used for preloader text */ line-height:400px; text-align:center; }NOTE: You might want to change the value left:50%; in the above code to make the necessary adjustment to the location of the box that displays the zoomed image.
- Save your template.
- To add the zoom effect to a particular image, just add class=”zoom” inside the image’s <a></a> tag. See the example below:
<class="zoom" a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiK17RONDx10oI-jOmwzWXA_cYjo5cmPsXiQwSfJEEWYJ1ZBTsFZ1yUge31z8rpCyp00FGQXNzIJs6tIH2SJ4sobPTKqteXaOqfyxBHeJ7tFEQ1bdqGzqVuyd6VAwBlWjzk_d3hPPf4Bm8/s1600/best-nature-full-hd-wallpapers-17.jpg" rel="softFocus: true, position:'inside', smoothMove:2"><img height="180" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiK17RONDx10oI-jOmwzWXA_cYjo5cmPsXiQwSfJEEWYJ1ZBTsFZ1yUge31z8rpCyp00FGQXNzIJs6tIH2SJ4sobPTKqteXaOqfyxBHeJ7tFEQ1bdqGzqVuyd6VAwBlWjzk_d3hPPf4Bm8/s320/best-nature-full-hd-wallpapers-17.jpg" width="320" /></a></div>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation.
0 comments:
Post a Comment