CSS Spoiler Only With Label And Input

unfortunately the details and summary tags are not allowed in AMP HTML. So the CSS spoiler only with details and summary can only be used for HTML5 templates only. 


For CSS only spoilers to be used in HTML5 and AMP HTML then we need another way to create them. 

Still remember with my post about fixed slide Blogger popular posts AMP HTML ? There I used the label label and input for the close widget button. 

From there I can idea to make CSS spoiler only with label and input . The Demo can be tried in amp-iframe Codepen.io below.  How cool is not it? If you want to try it on your blog, please follow the steps below. 

Please save the CSS code below in your blog's CSS style . 

.spoiler .spoiler_title { 
display: inline; 
float: left; 
margin: 3px 10px 0 0; 
padding: 4px 0; 
font-size: 16px; 
line-height: 1; 
} 
.spoiler label { 
cursor: pointer; 
background: #26272a; 
margin: 0; 
padding: 4px 18px 4px 22px; 
outline: none; 
border-radius: 3px; 
color: #efefef; 
transition: all .3s ease-in-out; 
display: inline; 
font-size: 12px; 
font-family: arial, san-serif; 
line-height: 1; 
position: relative; 
} 
.spoiler input[type=checkbox] ~ label:before { 
content: ""; 
height: 0; 
width: 0; 
border-width: 4px 4px 4px 7px; 
border-style: solid; 
border-color: transparent transparent transparent #fff; 
position: absolute; 
top: 7px; 
left: 8px; 
} 
.spoiler input[type=checkbox]:checked ~ label:before { 
content: ""; 
height: 0; 
width: 0; 
border-width: 7px 4px 4px 4px; 
border-style: solid; 
border-color: #fff transparent transparent transparent; 
position: absolute; 
top: 8px; 
left: 8px; 
} 
.spoiler input { 
position: absolute; 
left: -999em; 
opacity: 0; 
} 
.spoiler .content_box { 
width: 100%; 
border: 1px solid #ddd; 
background: #efefef; 
height: auto; 
padding: 6px 10px; 
margin: 8px 0 0; 
overflow: hidden; 
-moz-box-sizing: border-box; 
-webkit-box-sizing: border-box; 
box-sizing: border-box; 
} 
.spoiler .content_box .content { 
display: none; 
} 
.spoiler .content p { 
padding: 0; 
margin: 0 
} 
.spoiler .content p img { 
margin: 4px 0 0; 
max-width: 100%; 
height: auto; 
} 
.spoiler input[type=checkbox]:checked ~ .content_box .content { 
display: block; 
-webkit-animation: slide-down .3s ease-out; 
-moz-animation: slide-down .3s ease-out; 
} 
@-webkit-keyframes slide-down { 
0% { 
opacity: 0; 
-webkit-transform: translateY(-100%) 
} 
100% { 
opacity: 1; 
-webkit-transform: translateY(0) 
} 
} 
@-moz-keyframes slide-down { 
0% { 
opacity: 0; 
-moz-transform: translateY(-100%) 
} 
100% { 
opacity: 1; 
-moz-transform: translateY(0) 
} 
} 

Then please use the HTML code below each will insert a spoiler inside the post (in HTML mode). 

<div class="spoiler">  
  <span class="spoiler_title">Spoiler: 
  </span>  
  <input type="checkbox" id="item-1">  
  <label for="item-1">Hint
  </label>  
  <div class="content_box">    
    <div class="content">      
      <p>Save content here.....
      </p>      
      <br/>      
      <p>Or you can save images here......
      </p>    
    </div>  
  </div>
</div>

Note the item-1 code in the input and label tags must be the same. If you want to use more than 1 spoiler in the post, then change item-1 to item-2 , item-3 , and so on for second spoiler, third spoiler, and so on. 

And keep in mind! It turns out that in AMP HTML can not save the amp-img inside the spoiler, unless the spoiler opens first. 

Comments

  1. Wonderful blog! І found it whilе surfing around on Yahoo News.
    Do you have any suggestions on hoѡ to ցet listed
    in Yahoo News? I'vе been trying for a while bᥙt I never sееm to get theге!
    Mɑny thanks

    ReplyDelete
  2. You aϲtually make it аppear so easy ɑlong with үour presentation but
    I in finding tһіs topic to Ƅe really something wһich Ι think I might
    never understand. It seems too complex аnd vеry extensive foг me.
    Ι am looking forward in yоur subsequent рut up,
    I'll attempt tօ ցеt the hold of it!

    ReplyDelete
  3. I am realⅼy thankful tߋ the owner of thіs website who has shared thiis fantastic post aat ɑt tһis time.

    ReplyDelete
  4. Informative article, exactly what I needed.

    ReplyDelete
  5. I am sure this piece of writing has touched all the internet users, its really really good post on building up new blog.

    ReplyDelete
  6. Howdy would you mind letting me know which hosting company you're working with?
    I've loaded your blog in 3 different web browsers and I musst say this blog loads a lot faster then most.
    Can you recommend a good web hosting provider at a reasonable
    price? Thanks a lot, I appreciate it!

    ReplyDelete
  7. Your method of describing the whole thing in this post is in fact good, every one be capable of simply be aware of it, Thanks a lot.

    ReplyDelete
  8. This comment has been removed by a blog administrator.

    ReplyDelete
  9. This comment has been removed by a blog administrator.

    ReplyDelete
  10. I don't even know how I ended up here, but I thought
    this post was great. I do not know who you are but certainly you're going to a famous blogger if
    youu aren't already ;) Cheers!

    ReplyDelete

Post a Comment

Bila Ada posting yang kurang, atau error atau yang lainnya, silahkan tinggalkan komentar agar artikel/post di perbaiki.
Jangan Lupa Cek Box "Notify Me" agar tahu komentar kamu dibalas oleh saya.

If there are any posts that are missing, or error or anything else, please leave a comment for the article / post to be fixed.
Do not Forget Check Box "Notify Me" to know our comments replied by me.

Popular posts from this blog

Install deb package via Termux

How to Make Blogger Safelink Converter v3

List of weapon buff materials, effects and how it can be durango wild lands