How to hide scrollbar in iframe, but still be able

2019-05-23 07:48发布

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;
    }     

4条回答
该账号已被封号
2楼-- · 2019-05-23 07:52

For Webkit only, try adding:

::-webkit-scrollbar {
    display: none;
}
查看更多
▲ chillily
3楼-- · 2019-05-23 07:56

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

查看更多
Summer. ? 凉城
4楼-- · 2019-05-23 08:07

Just use this simple css code it will hide scrollbar

body {
overflow: hidden;
}
html {
  overflow:   scroll;
}
::-webkit-scrollbar {
    width: 0px;
    background: transparent; /* make scrollbar transparent */
}

查看更多
Deceive 欺骗
5楼-- · 2019-05-23 08:17

not sure if this possible with css for iframe only, but you can use scrolling='no'

<iframe frameborder="0" scrolling="no" src="https://google.com/"></iframe>
查看更多
登录 后发表回答