Html 如何在div标签中隐藏水平滚动条

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3235583/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 03:45:53  来源:igfitidea点击:

how to hide horizontal scrollbar in div tag

htmlscrollbarhidden

提问by ngmajid

I have a divwith size x=540px y=600px

我有一个div尺寸 x=540px y=600px

I want to hide horizontal scroll bar even if text is bigger than x size.

即使文本大于 x 大小,我也想隐藏水平滚动条。

How can i hide just the horizontal scroll bar?

如何只隐藏水平滚动条?

回答by rob waminal

use overflow-x

使用溢出-x

<div class="MyDivClass"></div>

CSS:

CSS:

.MyDivClass {
    height: 600px;
    width: 540px;
    overflow-x: hidden;
}

if you also want to hide the vertical use overflow-y: hidden;or for both just overflow: hidden;

如果您还想隐藏垂直使用overflow-y: hidden;或两者兼而有之overflow: hidden;

回答by user1685515

.MyDivClass {
    height: 600px;
    width: 540px;
    overflow-x: hidden;
}

回答by webslatesoftware

Use overflow-x: hiddenin body tag to hide horizontal scroll bar on whole HTML page

overflow-x: hidden在 body 标签中使用以隐藏整个 HTML 页面上的水平滚动条

body {
    background: none repeat scroll 0 0 #757575;
    font: 100%/1.4 Verdana,Arial,Helvetica,sans-serif;
    margin: 0;
    padding: 0;
    height: 600px;
    width: 540px;
    overflow-x: hidden;
}

回答by Alilu TAhiru

You can also nicely control that using below code

您还可以使用以下代码很好地控制它

.div{
    width: 540;
    height: 600px;
    overflow: scroll;
    overflow-x: hidden;
}