How to Hide empty div file if no url or link in your iframe?

User avatar
Dohangout
Admin
Admin
Contact:
Location: Philippines
Posts: 192
Joined: Sat Apr 23, 2016 10:32 pm

How to Hide empty div file if no url or link in your iframe?

Sat Mar 23, 2019 6:19 pm

If your into php and you have an empty iframe, all of the empty iframe link will be look like this below:
<div class="resp-container">
<iframe class="resp-iframe" src=(unknown) frameborder="0" sandbox="allow-same-origin allow-scripts" allowfullscreen="allowfullscreen"></iframe>
</div>
Hence <div class="resp-container"> have code in .css your page will have lot of empty space. To solve this:
<?php if($row['iframe_video']!='' && $row['iframe_video']!='unknown') echo '<div id="resp-container">
<iframe class="resp-iframe" src="'. $row["iframe_video"].'" frameborder="0" sandbox="allow-same-origin allow-scripts" allowfullscreen="allowfullscreen"></iframe>
</div>'; ?>
and since Our Iframe here is responsive. Here is the .css

Code: Select all

#resp-container {
    position: relative;
    overflow: hidden;
    padding-top: 56.25%;
}
.resp-iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}


Return to “WEB DESIGN, PHP, HTML”

Links

In total there are 10 users online :: 2 registered, 0 hidden and 8 guests
Registered users: Bing [Bot], Google [Bot]
Most users ever online was 19 on Mon May 20, 2019 11:06 pm
Total posts 525
Total topics 404
Total members 73
Our newest member Kelly
No birthdays today