I am working on a landing page with width 760px and need to have an iframe with content (a flash demo) that is 980px wide. So I would need to have a horizontal scrollbar in order to view the entire content. However, no matter what I add as scrolling attributes (e.g. scrolling="auto/yes" etc), nothing happens - no horizontal scrollbar at all.
The page displayed in the iframe has the following command in the source code:
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
overflow-x: hidden;
}
As far as I understand it, this is the reason why there is no horizontal scrollbar in my iframe. Is there any workaround for that to get one?
The overflow-x: scroll tells the web browser to clip the content if necessary. With this, the web browser displays scroll bars even if there is no clipped content. This means, if the content fits, you’ll observe a scroll bar that is not active.
With the horizontal scroll bars, you can scroll to see the content. All this is possible via a set of options that you can use with CSS overflow-x. This is the combination of overflow-x and its set of acceptable values.
A vertical scrollbar counts as part of the width of the viewport, meaning you’ll have horizontal overflow. Horizontal overflow means you’re going to see a horizontal scrollbar on the page.
You should use overflow-x: visible. If your content is hosted elsewhere you will not be able to change due to cross domain issues. Imagine if you own a website and someone else wants to iFrame your website and make changes to it ( if you could change the overflow, you could literally change any styling and that would be a huge security leak ).
You should wrap the iframe
in a containing div
, applying the fixed-width to the container.
-
<div class="container">
<iframe></iframe>
</div>
-
.container {
width: 980px;
height: auto;
overflow: scroll;
-webkit-overflow-scrolling: touch;
}
Try changing the iFrames (body/child) overflow with javascript.
Something like:
window.onload=function(){
document.getElementById(one).setStyles({ 'overflow': 'auto' });
};
maybe this, not sure which will get the body of the iframes contant:
window.onload=function(){
var frame = document.getElementById('one'),
frameDoc = frame.contentDocument || frame.contentWindow.document;
frameDoc.setStyles({ 'overflow': 'auto' });
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With