First look at the demo page to know what I am actually talking about.
Blogger Blogs encloses all of its content inside division with class name blog-posts, further each posts are wrapped inside a division with class name date-outer according to the date. And again inside date-outer block, each posts will be blocked in post-outer.
In this tutorial I am assuming that you don't have multiple posts in single day. First we'll have to tweak the CSS code which will bring all of the posts one above another like in photo slide.
Note: If you don't know the codding thing and just want to get it done then click here.
To do so, we'll use following code:
.blog-posts {
height:400px;
position:relative;
overflow:hidden;
}
.date-outer {
position:absolute;
top:0;
left:0;
background:#fff;
}
We have abosolutely positioned all the date-outer blocks relative to .blog-posts. In simple words, We have placed all the content blocks one above another. You can change the height of the main box to your required size. Now anything left is to add sliding effect to it so that the contents keeps sliding one over another.
I'll be tweaking the codes of small jQuery content slider technique so that it properly fits to Blogger's Posts.
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js' type='text/javascript'/>
<script type='text/javascript'>
var x = 2;
function slideSwitch() {
x += 1;
if (x > 4) {
x = 1;
}
$(".blog-posts div.date-outer:nth-child(n)").animate({opacity:0}).css('z-index' , '-1000');
$(".blog-posts div.date-outer:nth-child(" + (x) + ")").animate({opacity:1}).css('z-index' , '1');
}
$(document).ready(function() {
setInterval( "slideSwitch()",5000);
});
</script>
Copy the above code just below </title> tag.This will do the job. But we are not done yet. We'll have to tweak it again so that it will appear only in home page.
Easy Steps
Search for </title>, and paste the following code below </title>.
<b:if cond='data:blog.url== data:blog.homepageUrl'>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js' type='text/javascript'/>
<script type='text/javascript'>
var x = 2;
function slideSwitch() {
x += 1;
if (x > 4) {
x = 1;
}
$(".blog-posts div.date-outer:nth-child(n)").animate({opacity:0}).css('z-index' , '-1000');
$(".blog-posts div.date-outer:nth-child(" + (x) + ")").animate({opacity:1}).css('z-index' , '1');
}
$(document).ready(function() {
setInterval( "slideSwitch()", 5000 );
});
</script>
<style type='text/css'>
.blog-posts {
height:450px;
position:relative;
overflow:hidden;
}
.date-outer {
position:absolute;
top:0;
left:0;
background:#fff;
}</style>
</b:if>
Simply done, you'll have automatically updated content slider at your home page and normal page inside your posts.If you liked this article Bookmark and Subscribe us.
I have followed your instructions precisely, inserting all codes in my html template in blogger.
ReplyDeleteSorry for asking this silly question:
Now that all code blocks are in placed, how do I go about actually implementing the Automatic Content Slider for Blogger. Where is the Content Slider Code to insert in my publication section of my blog?
Thank you for your response.
Jose M.
@Jose:
ReplyDeleteCan I have a look at a template you are working at. This is not specific widget, rather it converts your current blog posts to animated slideshow.
You can have a look at demo.