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

发布于 2024-09-09 09:15:54 字数 100 浏览 7 评论 0原文

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

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

如何只隐藏水平滚动条?

I have a div with size x=540px y=600px

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

How can i hide just the horizontal scroll bar?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

对你的占有欲 2024-09-16 09:15:54

使用overflow-x

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

CSS:

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

如果您还想隐藏垂直方向,请使用overflow-y:hidden;或两者都只是overflow:hidden;

use overflow-x

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

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;

苏大泽ㄣ 2024-09-16 09:15:54
.MyDivClass {
    height: 600px;
    width: 540px;
    overflow-x: hidden;
}
.MyDivClass {
    height: 600px;
    width: 540px;
    overflow-x: hidden;
}
⒈起吃苦の倖褔 2024-09-16 09:15:54

在body标签中使用overflow-x:hidden来隐藏整个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;
}

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

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;
}
薯片软お妹 2024-09-16 09:15:54

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

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

You can also nicely control that using below code

.div{
    width: 540;
    height: 600px;
    overflow: scroll;
    overflow-x: hidden;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文