Div vertical scrollbar show

HtmlCss

Html Problem Overview


I am wondering how its possible to permanently show the vertical bar of a div (greyed out if there is no scrolling) similar to our regular bars. Basically I am trying to place an entire website in a div (like gmail/facebook), so if the page is not long enough the whole page shifts because of the lack of the vertical scroll bar.

I need a solution to this problem. I tried overflow-y:scroll. But it doesn't seem to work at all.

Html Solutions


Solution 1 - Html

What browser are you testing in?

What DOCType have you set?

How exactly are you declaring your CSS?

Are you sure you haven't missed a ; before/after the overflow-y: scroll?

I've just tested the following in IE7 and Firefox and it works fine

test


test
test
test
test
test
test
test
test
test
test

Solution 2 - Html

Have you tried overflow-y:auto ? It is not exactly what you want, as the scrollbar will appear only when needed.

Solution 3 - Html

Always : If you always want vertical scrollbar, use overflow-y: scroll;

jsFiddle:

<div style="overflow-y: scroll;">
......
</div>

When needed: If you only want vertical scrollbar when needed, use overflow-y: auto; (You need to specify a height in this case)

jsFiddle:

<div style="overflow-y: auto; height:150px; ">
....
</div>

Solution 4 - Html

In reactjs...

<div className='p-4 mb-4' style={{overflowY:'scroll',height:'350px'}}>
	{msgx.map((m,index)=>{
		return(
			<Items m={m} key={index} i={index}/>
		)
	})}
</div>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAlec SmartView Question on Stackoverflow
Solution 1 - HtmlEoin CampbellView Answer on Stackoverflow
Solution 2 - HtmlkgiannakakisView Answer on Stackoverflow
Solution 3 - HtmlRazan PaulView Answer on Stackoverflow
Solution 4 - HtmlChristian Umbrella CorpView Answer on Stackoverflow