유튜브 반응형 동영상 삽입
<
script
type
=
"text/javascript"
>
resizeYoutube();
$(window).resize(function(){resizeYoutube();});
$(function(){resizeYoutube();});
function resizeYoutube(){ $("iframe").each(function(){ if( /^https?:\/\/www.youtube.com\/embed\//g.test($(this).attr("src")) ){ $(this).css("width","100%"); $(this).css("height",Math.ceil( parseInt($(this).css("width")) * 480 / 854 ) + "px");} }); }
</
script
>
< iframe width = "854" height = "480" src = "https://www.youtube.com/embed/a4IosLAbLXY" frameborder = "0" allowfullscreen = "" ></ iframe >
출처 http://sometimes-n.tistory.com/42
다 필요 없다...
<div class="videoArea">
<iframe></iframe>
</div>
.videoArea{position:relative;width:100%;height:0;padding-bottom:56.25%;}
.videoArea iframe {position:absolute;top:0;left:0;width:100%;height:100%;}
|
댓글
댓글 쓰기