I have added slideshare iframe with presentation to my page
Code: <iframe src="//www.slideshare.net/slideshow/embed_code/key/HQoiz6GR1oLe1n" width="860" height="600" frameborder="600" marginwidth="0" marginheight="0" scrolling="no" style="border:1px solid #CCC; border-width:1px; margin-bottom:5px; max-width: 100%;" allowfullscreen> </iframe>
But when I open page at mobile phone there appear black area around presentation:
screnshot
I know that it happens because of style height="600", but when I remove it presentation becames small. How to remove this black areas around presentation?
With some CSS it’s very easy to make slideshare embeds that scale the height in relation to the actual width.
You need to add an outer , with 0 height, and 100% width, and a padding-bottom as percentage of the aspect ratio (eg 9 / 16 = 56.25%) with an extra padding of 38px for the slide navigation.
<div class="iframe-slideshare-16x9">
<iframe src="//www.slideshare.net/slideshow/embed_code/key/h1Fw1vmfv5uVlM"
frameborder="0"
marginwidth="0"
marginheight="0"
scrolling="no"
allowfullscreen>
</iframe>
</div>
The CSS looks like this:
.iframe-slideshare-16x9 {
padding-bottom: calc(56.25% + 38px);
position: relative;
width: 100%;
height: 0;
}
.iframe-slideshare-16x9 iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border:1px solid #CCC;
}
More on this, at my blog: https://nathan.gs/2018/01/07/responsive-slideshare-iframe/
this is not issue with iframe as your iframe is working properly and it is responsive
the problem is images/slides in slideshare iframe are bit small in height and I believe you cant do anything about it
hope it helps
Add the following media query to your css:
#media (max-width: 667px) {
iframe {
width: 280px;
}
}
Feel free to tweak values as desired.
Related
I'm using Atlantic theme and I create a new page for Map.
I used the following code which is mention below
<iframe src="https://www.google.com/maps/embed?pb=!1m14!1m8!1m3!1d27728.56583382997!2d-95.647502!3d29.688729!3m2!..." width="800" height="600" frameborder="0" style="border:0;" allowfullscreen="">
Please help me to get it to the full size, I have used the creating new layout method but still it does not work.
It only worked when I wrote the layout null {% layout none %}
But I wan it with the theme
I don't want to make the layout null.
The screenshot is attached below
Set the height and width of the <iframe> to 100% with CSS:
html, body, iframe {
height: 100%;
width: 100%;
padding: 0px;
margin: 0px;
}
proof of concept fiddle
code snippet:
html,
body,
iframe {
height: 100%;
width: 100%;
padding: 0px;
margin: 0px;
}
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3466.07056567071!2d-95.64969038455021!3d29.688733742242416!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x8640df708f47547b%3A0x21b117877ecdc1e7!2sMW%20Furniture%20Outlet!5e0!3m2!1sen!2sus!4v1571677313661!5m2!1sen!2sus"
frameborder="0" style="border:0;" allowfullscreen=""></iframe>
TL;DR: I need a scaled iFrame to be centered on larger screen sizes. I know this is a problem due to absolute positioning in the method.
I'm trying to embed an iFrame (YouTube video specifically) to a website. As it's 2017, I want the site to be responsive, and naturally, I want the embedded video to be responsive as well. So I found some code online that does this, it appears to be the common method for responsively sizing iFrames. I understand what's going on here.
Relevant HTML:
<div class="videoWrapper">
<iframe width="530" height="315" src="https://www.youtube.com/embed/4OJWC1tn_t4" frameborder="0" allowfullscreen>
</iframe>
</div>
Relevant CSS:
.videoWrapper {
position: relative;
padding-bottom: 56.25%;
height: 0;
padding-top: 20px;
overflow: hidden;
}
.videoWrapper iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
This is where the above code gets us to.
This works fairly well, but the video takes up 100% of the container space. It should though, it's coded that way. But what if I don't want it to do that? It looks really bad on larger screen sizes to have a video take up the whole window. I couldn't find an answer to making this not happen, so I tried putting my "videoWrapper" within another called "videoSizer" and scaling that down to width: 60% with height: auto when the screen size is greater than 480px.
Relevant HTML:
<div class="videoSizer">
<div class="videoWrapper">
<iframe width="530" height="315" src="https://www.youtube.com/embed/4OJWC1tn_t4" frameborder="0" allowfullscreen>
</iframe>
</div>
</div>
Relevant CSS:
#media only screen and (min-width: 480px) {
.videoSizer {
width: 60%;
height: auto;
}
}
This is where the above code gets us to.
So the size is about where I want it, and it looks nice on the page, but it's stuck in the top left corner of its container. That's how it should be, it's coded to that absolute position in the container. It's doing what I told it to. However, what I don't understand, and herein lies the problem, when I change the position coding in any way that I've thought of so far, the container size stays the same, but the iFrame element disappears.
So I would like to get the video centered on the site without it taking up 100% of the window, but am out of ideas and knowledge of how to have that happen. If anybody had any suggestions, I'd be really appreciative! I hope I've written this in a way that's descriptive enough and has enough resources attached to adequately explain the problem.
Answer (credit to LKG for helping me find it):
Remove #media query mentioned above. Not necessary, and creates problems.
Code as in LKG's answer, seen below.
To properly calculate bottom padding based on this:
- Add margin and element widths together
- Divide element width by margin width (we'll call this p1)
- Divide iFrame element height by width (call this p2)
- Multiply p1 by p2
- Answer is your new padding-bottom value
Just change css to get center
.videoWrapper iframe {
position: absolute;
top: 0;
left: 0;
right:0;
margin:auto;
}
html,
body {
margin: 0;
padding: 0;
}
.videoWrapper {
position: relative;
padding-bottom: 56.25%;
height: 0;
padding-top: 20px;
overflow: hidden;
}
.videoWrapper iframe {
position: absolute;
top: 0;
left: 0;
right: 0;
margin: auto;
}
<div class="videoWrapper">
<iframe width="530" height="315" src="https://www.youtube.com/embed/4OJWC1tn_t4" frameborder="0" allowfullscreen>
</iframe>
</div>
CSS:
.vertical-center {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
}
HTML:
<div class="vertical-center">
<iframe width="560" height="315" src="../assets/video.mp4" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen>
<p>Error loading video</p>
</iframe>
</div>
So i have this issue. i'm tryng to adjust and html inside an iframe , and i keep bangging my head arround this. the Html contains an image slider and my objective is that the image slider fills the entire iframe.
this is the html of the iframe, targgeting the index1.html:
<iframe height="520px" width="100%" src="index1.html" name="frame" style="border: none"></iframe>
and here is the css that controls the index1 image slider dimensions
body{
padding: 0px;
margin:0px;
}
#container{
width: 1298px;
height: 520px;
padding: 0px;
margin-top:0px;
margin-left:0px;
}
#slider{
position: center;
overflow: hidden;
width: 1298px;
height: 520px;
padding: 0px;
margin-top:0px;
margin-left:0px;
}
Every time i try to adjust te height of both image slider and it's container, the i frame creates a scroll.
The results i'm getting is the following:
please view image
That red marked grey area is the remaining of the iframe that i can't get the image slide fit into.
How can i do this?
Use either scrolling="no" or overflow: hidden;
<iframe height="520px" width="100%" src="index1.html" name="frame" scrolling="no" style="border: none; overflow: hidden;"></iframe>
You should probably look and see if some part of the "index1.html" is wider than the image slider. Pay attention to margins, padding, and borders. I would look into this before you try my suggestion above, because if there is some part of the content being hidden it may cause you issues later.
I am trying to embed a video from YouTube into my site. I am wondering if there is a way to relate the width and height based on the window size. For example, on an iPhone it looks something like THIS. Can I make the video shrink in width to smaller than the display size? Can I tie in my responsive site somehow, to get that?
It works great on computers or other larger screened devices, but not mobile.
Source:
<center><iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/zRDi1DT3AFA?rel=0" frameborder="0" allowfullscreen></iframe></center>
Full page source
Thanks for the help!
[edit: source]
It is possible to embed Youtube videos responsive by overriding the Youtube style (CSS).
Add the following CSS:
.video-con {
position: relative;
padding-bottom: 56.25%;
padding-top: 30px;
height: 0;
overflow: hidden;
}
.video-con iframe,
.video-con object,
.video-con embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
And then wrap the iframe with div:
<div class="video-con">
<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/zRDi1DT3AFA?rel=0" frameborder="0" allowfullscreen></iframe>
</div>
I set up a iframe like below
<iframe src="http://www.bbc.com/" frameborder="0" width="100%"></iframe>
CSS
iframe { overflow:hidden;
min-height:600px}
2 horizontal scrolling bars appear, 1 is at the iframe and the other is at the browser.
I want to get rid of the bar at iframe, I try
<iframe src="yahoo.com" scrolling="no" frameborder="0" width="100%"></iframe>
Then the scrolling bar at the iframe disappeared, and the problem is I cannot see anything at the bottom of BBC website!
I could increase min-height to greater number to cover entire length of BBC's page, but sometimes the page is very short and I'll get a huge white space at the bottom! So that increase the min-height is not a good practice.
How can I remove the scrolling bar at the iframe and use the browser's scrolling bar to navigate the page up and down?
Thank you!
There are different ways of doing this. There's jQuery solutions too. This will help you get started:
DEMO: http://jsbin.com/voqubo/1
CSS
body,html {padding:0;margin:0;height:100%;}
html {overflow-y:auto}
.embed-container {
position: relative;
height: 100%;
max-width: 100%;
}
.embed-container iframe,
.embed-container object,
.embed-container embed {
position: absolute;
top: 0;
left: 0;
bottom: 0;
width: 100%;
height: 100%;
}
HTML
<div class='embed-container'><iframe src='http://www.bbc.com/' style='border:0'></iframe></div>
<iframe
src="http://maroof.sa/Business/GetStamp?bid=203783"
style=" width: auto; height: 250px; overflow-y:hidden; "
frameborder="0"
seamless='seamless'
scrollable="no">
</iframe>