Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML iframe - disable scroll

Tags:

html

css

iframe

I have following iframe in my site:

<iframe src="<<URL>>" height="800" width="800" sandbox="allow-same-origin allow-scripts allow-forms" scrolling="no" style="overflow: hidden"></iframe> 

And it has scrolling bars.
How to get rid of them?

like image 921
Michał Herman Avatar asked Mar 19 '13 08:03

Michał Herman


People also ask

How do I turn off iframe scrolling?

1) Set the scrolling attribute of the iframe to no (scrolling="no"). This will disable both horizontal and vertical scroll bars. 2) Set the width attribute of the iframe to 200% (width="200%"). This will enable only the horizontal scroll bar.

How can I hide scrollbar in iframe but still scroll?

1. Set the overflow of the parent div as hidden. 2. Set the overflow of the child div to auto and the width 200% (or anything more than 100%, or more than the width of the parent - so that the scrollbar gets hidden).

How can I disable clicks but still allow scrolling in an iframe?

1 Answer. Show activity on this post. If you don't want the contents of the iframe to be interactable by the user, you can disable pointer-events on it. But as you want it to be scrollable, just put a full sized iframe in a smaller div with overflow: scroll.


2 Answers

Unfortunately I do not believe it's possible in fully-conforming HTML5 with just HTML and CSS properties. Fortunately however, most browsers do still support the scrolling property (which was removed from the HTML5 specification).

overflow isn't a solution for HTML5 as the only modern browser which wrongly supports this is Firefox.

A current solution would be to combine the two:

<iframe src="" scrolling="no"></iframe> 
iframe {   overflow: hidden; } 

But this could be rendered obsolete as browsers update. You may want to check this for a JavaScript solution: http://www.christersvensson.com/html-tool/iframe.htm

Edit: I've checked and scrolling="no" will work in IE10, Chrome 25 and Opera 12.12.

like image 127
James Donnelly Avatar answered Sep 21 '22 17:09

James Donnelly


I solved the same issue with this css:

    pointer-events:none; 
like image 30
John Smith Avatar answered Sep 23 '22 17:09

John Smith