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
how to hide horizontal scrollbar in div tag
提问by ngmajid
I have a div
with 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: hidden
in 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;
}