Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 5th Jun 2017, 06:49 PM   #1
Online for Offline
War Room Member
 
zoro's Avatar
 
Join Date: 2008
Location: Qld. Australia.
Posts: 1,628
Thanks: 352
Thanked 222 Times in 191 Posts
Blog Entries: 4
Default
iFrame Not Mobile Friendly - How Can I Fix?
Share on: 
fb share twitter share gplus share more share

I recently installed some iFrame script into one of the pages of my Wordpress site. Unfortunately the contents within the iFrame is not scaling compatible with Mobile Phone screens.
Is there a way I can make the iFrame script work on mobiles?
zoro is offline  
Unread 6th Jun 2017, 03:39 AM   #2
Digital Marketer
 
Marcus W K Wong's Avatar
 
Join Date: 2016
Location: Sydney, Australia
Posts: 223
Thanks: 188
Thanked 251 Times in 138 Posts
Default
Re: iFrame Not Mobile Friendly - How Can I Fix?
Share on: 
fb share twitter share gplus share more share

Wrap the iframe in a responsive wrapper and set the iframe to width:100%, and the wrapper is your max-width.

There's a few snippets already online on how to do it (I'm assuming your embedding a YouTube video at the moment).

Here's effectively what I use:

Working version here:
Edit fiddle - JSFiddle


CSS:

.videoWrapper {
position: relative;
padding-bottom: 56.25%; /* 16:9 */
padding-top: 25px;
height: 0;
}
.videoWrapper iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}


HTML

<~div class="videoWrapper">
<~iframe src="//www.youtube.com/embed/9fSde2DD8YQ"><~/iframe>
<~/div>

*** remove the '~' in the div and iframe tags above
Marcus W K Wong is offline  
The Following User Says Thank You to Marcus W K Wong For This Useful Post:
Unread 8th Jun 2017, 12:04 AM   #3
Online for Offline
War Room Member
 
zoro's Avatar
 
Join Date: 2008
Location: Qld. Australia.
Posts: 1,628
Thanks: 352
Thanked 222 Times in 191 Posts
Blog Entries: 4
Default
Re: iFrame Not Mobile Friendly - How Can I Fix?
Share on: 
fb share twitter share gplus share more share

Thanks Mate!

I am actually trying to embed a whole html page into a Wordpress page using an iFrame. If I just change the width to 100% will it be mobile friendly?

Originally Posted by Marcus W K Wong View Post

Wrap the iframe in a responsive wrapper and set the iframe to width:100%, and the wrapper is your max-width.

There's a few snippets already online on how to do it (I'm assuming your embedding a YouTube video at the moment).

Here's effectively what I use:

Working version here:
Edit fiddle - JSFiddle


CSS:

.videoWrapper {
position: relative;
padding-bottom: 56.25%; /* 16:9 */
padding-top: 25px;
height: 0;
}
.videoWrapper iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}


HTML

<~div class="videoWrapper">
<~iframe src="//www.youtube.com/embed/9fSde2DD8YQ"><~/iframe>
<~/div>

*** remove the '~' in the div and iframe tags above
zoro is offline  
Unread 12th Jul 2017, 09:15 PM   #4
Active Warrior
 
PsiCat's Avatar
 
Join Date: 2009
Posts: 59
Thanks: 24
Thanked 3 Times in 3 Posts
Default
RE: iFrame Not Mobile Friendly - How Can I Fix?
Share on: 
fb share twitter share gplus share more share

Markus, Your code is VERY close to what I need (THANKS!), but I just can't get it the rest of the way.

I am trying to make a responsive youtube container that is centered on the screen with 10% white space on either side.

I did this with the iframe in the Edit fiddle - JSFiddle link you provided, and it looks very close to what I want, but then it pushes the content below the video down too far. It's like the responsive container is still the full size of the video but I'm only displaying in 80% of it and the rest is autofilled with invisible placeholder space which pushes my button below the fold.
.videoWrapper iframe {
position: absolute;
top: 0;
left: 10%;
width: 80%;
height: 80%;
}

Can you tell me how I can display a responsive youtube video sandwiched vertically between two images (like a website header on top and a button below) without a bunch of white space/padding between the images and the video?

Check out Miracle Mastery and explore the Psychic Development of *Physical* abilities you can actually see, like telekinesis and radical Healing!
PsiCat is offline  
Closed Thread


Bookmarks

Tags
fix, friendly, iframe, mobile


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 12:52 PM.