如何停止水平滚动

如何停止水平滚动

本文介绍了如何停止水平滚动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用html和javascript编写了一个文件。



因为垂直滚动应该存在,但是我想停止水平滚动。

$ b

解决方案

Sarfraz有 overflow-x ,这是一个回答,尽管它意味着(如它说!),任何已经向右边是现在不可用给用户。有这样的用例,但是在主要是不希望有用户不能访问的内容。



问题是:为什么你得到水平滚动在所有?在正常的事情过程中,浏览器将包装内容,使得不需要任何水平滚动。如果用户具有正常的窗口大小,则通过使用通过样式信息或具有不可封装内容(如大图像)指定为特定宽度的元素,您可以在设计中引起水平滚动。例如,这不需要水平滚动:

 < p> ...这里有很多文字...< ; / p> 

...但这将:

 < p style ='width:1200px'> ...这里有很多文字...< / p> 

...如果用户的浏览器窗口宽度小于1200像素。



所以如果内容不可用不是你想要的,我的答案将是找到导致滚动的元素并纠正它们。


I have written a file using html and javascript.

In that Vertical scrolling should be there, but i want to stop horizontal scrolling.

How can I do that?

解决方案

Sarfraz has already mentioned overflow-x, which is one answer although it means (as it says!) that anything that would have been off to the right is now unavailable to the user. There are use cases for that, but in the main it's undesireable to bother to have content the user can't access.

The question is: Why are you getting horizontal scrolling at all? In the normal course of things, the browser will wrap content such that there isn't any horizontal scrolling required. Provided the user has a normal-ish window size, you cause horizontal scrolling in your design by having elements that you've specified as being a certain width, either via style information or by having non-wrappable content (like a big image). For instance, this won't require horizontal scrolling:

<p>...lots of text here...</p>

...but this will:

<p style='width: 1200px'>...lots of text here...</p>

...if the user's browser window is less than 1200 pixels wide.

So if having the content off to the right unavailable isn't what you intend, my answer would be to find the elements causing the scrolling and correct them.

这篇关于如何停止水平滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 04:05