Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide scrollbar in iframe, but still be able to scroll

I have an iframe on a page with another page inside it. I want to hide the scrollbar but i can't find any solution for this. I have tried with overflow: hidden; but it's not working.

See Below Code:

    <iframe frameborder="0" src="https://google.com/"></iframe>

CSS Code:

   iframe{
      overflow: hidden;
    }     
like image 228
Mathias Hermansen Avatar asked Jan 13 '17 23:01

Mathias Hermansen


People also ask

How do I hide horizontal scrollbar but still scroll?

The second fiddle only scrolls horizontally, you can hold shift and then use mouse scroll to go left and right. I have also tested this in chrome and it works fine for me.

How do I stop scrolling without scrollbar hiding?

Disabling scroll with only CSS. There's another way to disable scrolling that is commonly used when opening modals or scrollable floating elements. And it is simply by adding the CSS property overflow: hidden; on the element you want to prevent the scroll.

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.


1 Answers

Since you didn't specify if you need a solution for the vertical or horizontal overflow, I am assuming you are talking about the vertical one.

This can be done with the help of the parent div.

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).

.container {
  width: 300px;
  overflow: hidden;
}

.child {
  width: 200%;
  height: 200px;
  overflow: auto;
}

jsfiddle

like image 79
aliengirl a.k.a. alien no.155 Avatar answered Nov 15 '22 06:11

aliengirl a.k.a. alien no.155