Html 水平滚动条
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13925284/
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
horizontal scrollbar
提问by ggcodes
How can I make an automatic horizontal scroll bar in my page if the content will overflow in its border.
如果内容将在其边框中溢出,如何在我的页面中制作自动水平滚动条。
<html>
<body>
<div style ="width: 20px; height:30px; border:1px solid black; overflow:auto">
<!-- various of text here that can makes it go out the border-->
</div>
</body>
</html>
What if the text in my content is too long, how can I make an automatic horizontal scrollbar?
如果我的内容中的文本太长,我该如何制作自动水平滚动条?
回答by onimojo
Insert in the div style :
在 div 样式中插入:
overflow-x:scroll;
回答by SyntaxError
change your code into this:
将您的代码更改为:
<html>
<body>
<div style ="width: 20px; height:30px; border:1px solid black; overflow-x:scroll">
<!-- various of text here that can makes it go out the border-->
</div>
</body>
</html>
回答by clyfish
回答by sooper
Change your style to this:
将您的样式更改为:
style="width: 20px; height:30px; border:1px solid black; overflow:auto;"
Just a case of incorrect syntax.
只是语法不正确的一种情况。
回答by Rahul Mehra
NOTE: In order to make text horizontally scrollable you will have to add overflow-x:scroll; overflow-y: hidden; white-space: nowrap;to your div.
注意:为了使文本水平滚动,您必须添加 overflow-x:scroll; 溢出-y:隐藏;空白:nowrap;到您的 div。
<html>
<body>
<div style ="width:20px; height:30px; border:1px solid black; overflow-x:scroll; overflow-y:hidden; white-space:nowrap;">
<!-- various of text here that can makes it go out the border-->
</div>
</body>
</html>