在div / img上禁用垂直滚动 [英] disable vertical scrolling on a div/img

查看:192
本文介绍了在div / img上禁用垂直滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站上有一个带有大图片(宽度为1000px)的标题。
此图像居中(水平)。如果用户使用宽度小于1000像素的浏览器窗口访问此网站,则可以水平滚动。这是我要防止的,因为图像的外部部分并不重要,并且页面的其余部分与用户浏览器窗口一样宽。

I have a header on my website with a large image ( 1000px width ). This image is centered (horizontally). If a user comes to this website with a browser window which is slimmer than 1000px in width, he can scroll horizontally. This is what I would like to prevent, since the outer parts of the image are not important and the rest of the page is as wide as the users browser window.

对于实例:
一个用户浏览器窗口的宽度为600px,我想发生的是:

For instance: A users browser window is 600px in width, what I would like to happen is:

图像的前200px不可见,接下来的600px可见,图像的最后200像素再次不可见。

The first 200px of the image are invisible, the next 600px are visible and the last 200px of the image are invisible again.

<html>
<body>
    <div id="outer" style="width:100%;overflow-x:hidden;">  
        <div id="inner" style="display: table;margin: 0 auto;width:1300px">
            <img src="image.jpg" alt="image" width="1300px">
        </div>
    </div>
</body>
</html>


推荐答案

您将需要使用CSS。 p>

You will need to use CSS for that.

div {
    overflow-x: hidden;
} 

这篇关于在div / img上禁用垂直滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆