| | #1 |
| Online for Offline War Room Member Join Date: 2008 Location: Qld. Australia.
Posts: 1,628
Thanks: 352
Thanked 222 Times in 191 Posts
Blog Entries: 4 |
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? |
| |
| | #2 |
| Digital Marketer Join Date: 2016 Location: Sydney, Australia
Posts: 223
Thanks: 188
Thanked 251 Times in 138 Posts
|
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 |
| |
| The Following User Says Thank You to Marcus W K Wong For This Useful Post: |
| | #3 | |
| Online for Offline War Room Member Join Date: 2008 Location: Qld. Australia.
Posts: 1,628
Thanks: 352
Thanked 222 Times in 191 Posts
Blog Entries: 4 |
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?
| |
| |
| | #4 |
| Active Warrior Join Date: 2009
Posts: 59
Thanks: 24
Thanked 3 Times in 3 Posts
|
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!
| |
| |
|
| Bookmarks |
| Tags |
| fix, friendly, iframe, mobile |
| |