I guess it’s because you used overflow: hidden and float at the same time.
It is necessary to understand the detailed explanation of CSS BFC and the origin of float and overflow: hidden. We have cleared the floats together in those years. I will post some related questions for you. Please understand more and find solutions: In CSS Why can overflow:hidden clear the impact of float? What is the principle?
Is your ulthere is something at the same level? height: 100% will inherit the height of the parent. If ulhas content at the same level, it will hold ul down. It is recommended to wrap a p suitable for the height on the outer layer, and write ulscroll inside the p
How about changing
height
to an absolute value? And your screenshotoverflow-y
isauto
. Why not usehidden
The screenshot is not very clear. Who is it 100% based on?
I guess it’s because you used overflow: hidden and float at the same time.
It is necessary to understand the detailed explanation of CSS BFC and the origin of float and overflow: hidden. We have cleared the floats together in those years.
I will post some related questions for you. Please understand more and find solutions:
In CSS Why can overflow:hidden clear the impact of float? What is the principle?
The outermost p needs to have a fixed height, and ul is the height: 100%;
Is your
ul
there is something at the same level?height: 100%
will inherit the height of the parent. Iful
has content at the same level, it will holdul
down. It is recommended to wrap ap
suitable for the height on the outer layer, and writeul
scrollinside the
pheight: 100% height is inherited from the upper layer