JavaScript | jquery 반응형 iframe
페이지 정보
- 작성자:
- 핵탐
- 작성일
- 01.03 11:55
- 조회
- 1,015
- 댓글
- 0
본문
[code]
function resizeIframe() {
const iframes = $('.view-content iframe');
iframes.each(function (idx, ele) {
const w = $(ele).width();
const h = $(ele).height();
const ratio = h / w * 100;
$(ele).wrap(`<div style="position:relative; padding-bottom:${ratio}%"></div>`);
$(ele).css({
'position': 'absolute',
'top': '0',
'left': '0',
'width': '100%',
'height': '100%'
});
})
}
$(document).ready(function() {
resizeIframe();
});
[/code]
댓글 0개
등록된 댓글이 없습니다.