Jacob
Jacob

Reputation: 4031

Scrollbar affecting the div width

I have a div with propertie overflow auto. How to make the content of this div horizontally aligned with and without the scrollbar displayed. The scrollbar is messing with the div width. I hope you understand.

Upvotes: 0

Views: 5546

Answers (2)

Vivek Kumar
Vivek Kumar

Reputation: 2909

Try using overflow-y: overlay instead.

.your-content{
   overflow-y: overlay;
}

NOTE::: overflow-y: overlay has been deprecated.

But this will make the scrollbar appear as an overlay without affecting the width of div or element.

Upvotes: 0

Ricain
Ricain

Reputation: 706

overflow-x: scroll;
overflow-y: hidden;

source: Div with horizontal scrolling only

Upvotes: 1

Related Questions