របៀប Embed Responsive iFrame វីដេអូ
ក្នុងអត្ថបទនេះដែរខ្ញុំនឹងបង្ហាញអ្នកទាំងអស់គ្នាពីរបៀប Embed Video លក្ខណៈ Responsive ដែលវារីករួមទៅតាមប្រភេទ Devices ផ្សេងៗដូចជា៖ Smart Phone, Tablet, Desktop... ជាដើម។ ១.ចូលទៅកាន់ Theme => Edit HTML រួចចម្លងកូដខាងក្រោមដាក់ពីខាងលើ </head>
<style type="text/css">
#iframe-player{position:relative;overflow:hidden;width:100%;height:100%;border-radius:5px}
.iframe-container{border:4px solid #ff0000}
.iframe-responsive{position:relative;overflow:hidden;width:100%;height:100%;padding-top:56.25%;background-color:rgb(0,0,0)}
.iframe-responsive iframe{position:absolute;top:0;left:0;width:100%;height:100%;border:0}
</style>២.ចម្លងកូដខាងក្រោមដាក់ពីខាងលើ </body> បន្ទាប់មកចុច Icon Save រួចចាកចេញពីផ្ទាំង Edit HTML <script type="text/javascript">
$('#iframe-player').each(function () {
let $this = $(this),
zeroIndex = 0,
buildIframe = "";
buildIframe += '<div class="iframe-container">';
buildIframe += '<div class="iframe-responsive">';
buildIframe += '<iframe id="video-iframe" src="' + embedSource[zeroIndex] + '" width="100%" height="100%" allowfullscreen="true" loading="lazy"></iframe>';
buildIframe += '</div></div>';
$this.html(buildIframe);
});
</script>៣.ចម្លងកូដខាងក្រោមដាក់ក្នុង Blog Post ដោយប្ដូរទៅជា HTML view <div id="iframe-player"></div>
<script>
let embedSource = ["https://vdoview.tumblr.com/?id=2648030186054"];
</script>៤.ផ្លាស់ប្ដូរ Link Video ខាងលើរួចចុចពាក្យ Publish ជាការស្រេច៕
Comments
Post a Comment