overflow-x-auto to a container with content wider than the container's width?<div class="w-48 overflow-x-auto border border-gray-400"> <div class="w-96 bg-blue-200">Wide content inside</div> </div>
overflow-x-auto does when content is wider than its container.The overflow-x-auto class adds a horizontal scrollbar only when the content overflows the container's width. This allows horizontal scrolling without clipping or expanding the container.
The overflow-hidden class hides overflow on both the x (horizontal) and y (vertical) axes. The others affect only one axis or add scrollbars.
overflow-y-scroll on a fixed height containeroverflow-y-scroll, what will you see in the browser?<div class="h-24 overflow-y-scroll border border-gray-500"> <p>Line 1</p> <p>Line 2</p> <p>Line 3</p> <p>Line 4</p> <p>Line 5</p> <p>Line 6</p> </div>
overflow-y-scroll does when content height exceeds container height.The overflow-y-scroll class always shows a vertical scrollbar, letting you scroll through content that exceeds the container's fixed height.
overflow-x-hidden hides horizontal overflow, while overflow-y-auto adds vertical scrollbar only if needed. This combination prevents horizontal scroll but allows vertical scrolling.
<div class="h-40 overflow-auto border p-2">
<!-- long content here -->
</div>Adding tabindex="0" makes the scrollable container focusable by keyboard users, allowing them to scroll using keyboard keys. Overflow classes alone do not provide keyboard focus.