undefinedfix
Sign in

How to make the horizontal scroll bar appear when there are too many contents in a div with fixed height?

jstoobz edited in Sun, 17 Apr 2022

That is, the content is on one line, but you can scroll left and right to see more text

4 Replies
yaser
commented on Sun, 17 Apr 2022

You need two boxes, fixed width and height on the outside, overflow:auto; The inside is wider or white than the outside- space:nowrap That's it.

<div style='width:200px;overflow:auto;'>
    <p style='white-space:nowrap'>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</p>
</div>
adampog
commented on Sun, 17 Apr 2022

Using white- space:nowrap To ban line breaks

Giorgi
commented on Mon, 18 Apr 2022

Add overflow-x: scroll to CSS

openHBP
commented on Mon, 18 Apr 2022

In CSS, set overflow-x: scroll as horizontal scroll bar and overflow-y: scroll as vertical scroll bar for Div.

lock This question has been locked and the reply function has been disabled.