Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove Iframe scrollbar but full page should load?

After adding Iframe inside contentArea, I am getting two scroll bars. I wanted to hide iframe scrollbar without hiding any content of external website link. How can I do that? I added the below snippet code and tried couple of things like scrollbar="no" but didn't work. Help me on this and thank you in advance.

I need contentArea scrollbar. Just wanted to hide iframe scrollbar without hiding external website content.

body{margin:0;padding:0;}
.contentArea{height:100%; width:100%; position:absolute; top:0;left:0;overflow-y:scroll;}
iframe{height:100%; width:100%; position:absolute; top:0;left:0;border:0;}
<div class="contentArea">
<iframe src="https://ajaymalhotra.in" title="Iframe Example"></iframe>
</div>
like image 583
Ajay Malhotra Avatar asked Aug 08 '20 17:08

Ajay Malhotra


People also ask

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 do I get rid of the scroll bar in iframe?

A simpler way is however, is to use a container div styled with overflow: hidden; to hide the scrollbar. Set the width and the height of the div, to be slightly less than that of your iframe. Hope this helps you.

How do I get rid of unnecessary scroll bar?

A quick fix is to add overflow: hidden to the CSS for your #footer . Note: A scrollbar will still appear if your #body content flows out of the the viewport. Show activity on this post. It will remove unnecessary scroll bars.

How do I hide the scrollbar in embed?

Use your embed tag inside a container with overflow hidden. Then set the width of the embed with 100% + 17px (the default width of a scrollbar).


2 Answers

You need to make the size of the iframe match the size of the content in the iframe. Their is no native way of doing this in the browser, and if your doing this cross-domain then you will need JS code on both the parent and in the iframe.

Here is a much longer answer that I wrote a few years ago on how to do this.

iframe Auto Adjust Height as content changes

Alternatively their is this library that will make things a lot simpler for you.

https://github.com/davidjbradshaw/iframe-resizer

like image 139
David Bradshaw Avatar answered Oct 21 '22 07:10

David Bradshaw


Try this, you will able to hide the scroll bar of iframe but you can still scroll your page

<div style='width: 500px; height: 120px; overflow: hidden;'>

    <iframe style='width: 518px; height: 120px;' src=''></iframe>

</div>
like image 26
Chetali Polekar Avatar answered Oct 21 '22 05:10

Chetali Polekar