The page you link won’t load but here are the basics to make a scrollable element:
HTML / JS Structure
- Make an outer container
div
- Make an inner container
div
(this will be the “scroll wrapper”) - Append the inner container to the outer container
- Insert whatever you need into the inner container (you can use something like
insertAdjacentHtml
or whatever works for your specific situation)
This order of steps in particular will work well for a scenario where the contents are dynamically changing.
CSS
-
For the outer container
- Set a fixed value for
width
and setheight: auto
- Set a
border-radius
if you want circular edges - Set
overflow: hidden
to keep the scroll wrapper’s corners from popping out - You will probably want some
padding
- Set a fixed value for
-
For the inner container
- Set
position: relative
- Set
overflow-y: auto
andoverflow-x: hidden
so that you can scroll up and down, but not side to side - For the desired overflow behavior, you need to set
width: 100%
and set fixed values formax-height
andmin-height
. (max-height
decides when things will start to overflow ie. make a scroll bar)- You will want
max-height
andmin-height
to be less than the outer container’s fixedwidth
+ anypadding
, etc. it may have.
- You will want
- Set