Reputation: 2899
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?
Upvotes: 6
Views: 76187
Reputation: 720
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.
<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>
Upvotes: 1
Reputation: 1752
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>
Upvotes: 11
Reputation: 6039
Change your style to this:
style="width: 20px; height:30px; border:1px solid black; overflow:auto;"
Just a case of incorrect syntax.
Upvotes: 1