Here's how to do it with CSS without JavaScript:
- Wrap your iframe in a div.
- Add
<input type='checkbox'> above the div and iframe. - Add
<label> after <input type='checkbox'> . - Hide
<input type='checkbox'> with display:none . - The div style will be invisible with
opacity:0 or visibility:hidden * - Add this rule set:
input:checked + label + div { visibility: visible; }
* display:none and display:block works, but it has the ability to break the layout.
The following snippet contains comments on comments
SNIPPET
body { background: black; } #chx1 { display: none; } label { font-size: 40px; text-decoration: none; color: #fC3; cursor: pointer; } label:hover { color: #0ff; } .expand { opacity: 0; height: 0; width: 480px; transition: opacity .4s, max-height 1s linear .3s; } #chx1:checked + label + .expand { opacity: 1; max-height: 270px; }
<input id='chx1' type='checkbox'> <label for='chx1'>✦</label> <div class='expand'> <iframe width="480" height="270" src="http://www.youtube.com/embed/o0u4M6vppCI" frameborder="0" allowfullscreen></iframe> </div>
source share