iFrame Hide Scroll bars but still be able to scrol

2019-02-15 14:45发布

问题:

What I am trying to do is make an iPhone simulator and just have a web page display in an iFrame. The scrollbars are taking up too much room so I want to hide them but still have the ability to scroll.

Here is the HTML:

<div id="iphone">
    <iframe src="http://site.com" width="307" height="443"><p>Your Browser does not support iFrames.</p></iframe>
</div>

CSS:

#iphone { background:url(iPhone.png) no-repeat; width:368px; height:706px; position:relative; overflow:hidden;  }
#iphone iframe { position:absolute; left:30px; top:143px; border:0;overflow:hidden; }

Right now it's working good, the scrollbars are hidden but I cannot scroll. I can use my Arrow keys and it works fine, but I really want the ability to use the mouse wheel

Does anyone have any ideas?

回答1:

This should give you what you need to detect the mouse wheel movement: http://www.adomas.org/javascript-mouse-wheel/

And this should give you what you need to control the scrolling of the page: http://www.mediacollege.com/internet/javascript/page/scroll.html

Detect mouse wheel, determine the direction, scroll accordingly.



标签: html css iframe