New Published Post: How To Fix Adsense Not Showing After Redirecting Blogger To Custom Domain
Like Us:
Facebook



Putting a Show - Hide Effect or Content Spoiler in Blogger


I have already shared an article on how to add read more in blogger. But in this article I'm gonna show a trick on how to "show more or show less" a long article  in a certain page or post. I've learned the initial  codes from Greenlava and I modified it to make this tweak more fitted to newbie bloggers. You can utilize the code in pages, posts and even in widgets.

Live Demo

content spoiler or show-hide effect

Here are the features of this Content Spoiler
  • The button text changes accordingly. The "show more" will appear if it is in the hide state or the texts are hidden and "show less" will appear if it is in the show state mood.
  • You can use this spoiler in multiple manner  even in a single page.
  • The spoiler will not work in Internet Explorer .

Putting a Show - Hide Effect or Content Spoiler in Blogger


Step 1. Log-in to your Blogger account
Step 2. Click the Template button ( have a back - up of your template)
Step 3. Hit the Edit HTML button
Step 4. Look for the code below
</head>
Step 5. And just above that code </head> paste the following css code
<style type='text/css'>
/* animated spoiler CSS by Bloggingtipsandtrix.blogspot.com */
.spoilerbutton {
display:block;
margin:5px 0;
}
.spoiler {
overflow:hidden;
background: #f5f5f5;
}
.spoiler &gt; div {
-webkit-transition: all 0.2s ease;
-moz-transition: margin 0.2s ease;
-o-transition: all 0.2s ease;
transition: margin 0.2s ease;
}
.spoilerbutton[value=&quot;Show - More&quot;] + .spoiler &gt; div {margin-top:-100%;}
.spoilerbutton[value=&quot;Show - Less&quot;] + .spoiler {padding:5px;}
</style>

Step 6. Save your template!
Everytime you want to use the content spoiler, just paste the HTML (code) below in your blogger editor's page (be sure to switch your blogger editor page in HTML mode)
<input class="spoilerbutton" onclick="this.value=this.value=='Show - More'?'Show - Less':'Show - More';" type="button" value="Show - More" />

<div class="spoiler">
<div>
Your text here that you want to hide
</div>
</div>

Customization
  • You can change the background color of the "Show - More/Show - Less" or the content spoiler button by replacing the hexadecimal color f5f5f5 with your own. You can use our color code generator.
  • Replace the text Show - More with "Show"  and Show - Less with "Hide" or any text that you want, both in css code (step 5) and in HTML (below step 6 code).
  • You can adjust the speed of the texts that you hide in getting in and out  by adjusting the texts in green (0.2s). The unit is in seconds (s), therefore if you will lower the number from 0.2 s to 0.1s the speed will increase and if you increase the number from 0.2s to 0.3s, 0.4s, 0.5s, 0.6s, 0.7s the speed of getting in and out will  decrease.
If you have some questions regarding this post, kindly drop it at the comment section below. Thank you and
God Bless Us All!
About the Author:
tilt  hover effect
Hello folks! This is Viral Apps, the admin of this blog. No words could described my grateful appreciations to all newbie and professional bloggers around the world and most especially to Almighty God who gave me the wisdom...Read More
Follow him @ Twitter |Facebook


Express yourself!
18 comments : Post Your's Buddies!

Post A Comment!
We love to hear your feedbacks and suggestions. We will try our best to reply to your queries as soon as time allows. Please Keep in mind that all comments are moderated manually by our editors team to minimize spamming, and all the links are nofollow.

Note:
1. To add HTML code in the box, please use our HTML editor generator.
2. Please do not spam. Those type of comments will be deleted upon our review.
3. We should appreciate an individual and suggestive discussion.

Best Regards,

Cerwenlloyd Gefjun
  1. i have my button but it is not working :( pls could you help me??

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. This comment has been removed by the author.

      Delete
    3. I have same problem as you. but I can resolve it by removing < br / >
      added by blogspot between these two line.

      value="Show - More" />

      < div class="spoiler">


      and then click update without change the editor to compose mode.

      Delete
    4. You are absoulutely right bro!Thanks for your valuable comment!

      Delete
  2. I think I'll be disappointed in the answer since it appears it is common practice for feeds to strip "dangerous" onclick attributes but is there any chance this works in feed readers?

    The one I use now doesn't, it shows the hidden text instead. But to make matters worse it just stopped working in email subscriptions too. Button lights up but in this case, text remains hidden.

    It will take alot of work for me to change methods but if yours works, atleast in email, I'll do so gladly.

    (and don't you just hate how blogger adds html where ever it wants! I swear it takes longer for me to remove worthless code than it does to write the post.)

    And thanks in advance :>)

    ReplyDelete
  3. Hello, hope you're doing ok tonight. today!
    I/ve sent you an email just a minute ago hope it answers your query Ma'am..
    Thanks for visiting!!!

    ReplyDelete
    Replies
    1. I'm well, thanks!

      I'm going to try it out on my next post. It is definitely less code than my current one. However I apologize because I did not make myself clear. Toggle works beautifully on the blog page when viewed directly.

      However, in feed readers and email subscriptions toggle does not work at all. In Feedreaders like Feedly, Live Bookmarks and default atom rss show the hidden content while email hides it, and you can't toggle to show.

      Since, unfortunately, a majority of our loyal readers use those two methods to read our posts, hiding content becomes problematic.

      From what I have read, "onclick" is likely the problem. It is considered to be a dangerous attribute so it is automatically stripped/removed.

      The extra "br" I understand and know to remove before I publish. Thank you for reminding me.

      I do have one question. Inside the "hidden" portion I am putting a CSS formatted blockquote. Is there any way to change the surrounding white box to another color?

      Delete
    2. Hello Ma'am, You can change the surrounding background white box by changing its border color..
      Hope it answer your question Ma'am...

      Delete
    3. At your service Ma'am! Stay connected and God Bless Your Families...

      Delete
  4. This doesn't work the button it there and the spoiler text is under the button and the button does nothing
    http://thelmgnfiles.blogspot.com/

    ReplyDelete
  5. Hello, I just tried out your script and it wonderfully does what it's supposed to do. My only problem is – it's causing the post in the center column of my blog to spread to the full width of my monitor, causing the side navigation to be squeezed underneath. Any idea on what's causing this, and how to avoid it? My blog has a 3 column layout.

    ReplyDelete
  6. I have been using this method on my blog, but there is one problem which is that when I zoom my blog, the text, which is supposed to be hidden, shows up (but not all). It means the spoiler cannot carry the long text. Is there any ways to fix this?

    ReplyDelete
  7. I've tried to get that Spoilertag into my blog for ours now an the best reult I was able to get is this
    http://doesthisthingreallywork.blogspot.co.uk/
    Please, can someone tell me, what the hell I'm doing wrong?

    ReplyDelete
    Replies
    1. Not an expert but it seems to work on dynamic classic just fine. The other dynamic views, not so much. What I do know is that dynamic views are very hard to edit. Heck blogger completely broke my dynamic views months ago so now all I get is a blank page.

      Delete
  8. Thanks. That's Perfectly worked for me.

    http://pricelistbd57.blogspot.com/

    ReplyDelete
  9. Is there any way to spoiler text in the comments section?
    Or is that just impossible?

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...