Skip to content

Instantly share code, notes, and snippets.

@meded90
Created April 3, 2015 09:45
Show Gist options
  • Select an option

  • Save meded90/19f3182730ae1a01ebb2 to your computer and use it in GitHub Desktop.

Select an option

Save meded90/19f3182730ae1a01ebb2 to your computer and use it in GitHub Desktop.
динамическое загрузка ютуб роликов для мобайла
<div class="videowrapper">
<a href="{{ url }}" target="_blank">
<img src="{{ img-url }}" alt=""/>
</a>
</div>
.videowrapper {
float: none;
clear: both;
width: 100%;
position: relative;
padding-bottom: 56.25%;
padding-top: 25px;
height: 0;
position: relative
a {
cursor: pointer
display: block
left: 0
top: 0
position: absolute
width: 100%
height: 100%
text-decoration: none !important
}
img {
left: 0
top: 0
position: absolute
width: 100%
}
iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
}
$('.videowrapper a').click(function () {
var $this = $(this);
var url = $this.attr('href');
$this.parent().append($('<iframe>').attr({
src: url+'?autoplay=1&rel=0&showinfo=0&border=0&iv_load_policy=3&modestbranding=1',
frameborder: "0",
allowfullscreen: null
}));
$this.remove()
return false
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment