CSS
iOS
scroll bar
overflow
web design

How to get the scroll bar with CSS overflow on iOS

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

Introduction

Scrollable containers that work fine on desktop Safari or Chrome often behave differently on iPhone and iPad. On iOS, the main issue is not whether overflow works; it is that Safari prefers overlay scroll indicators and touch scrolling, so you cannot force a traditional always-visible scrollbar the way many desktop browsers allow.

What iOS Actually Supports

For a container to scroll on iOS Safari, it needs a constrained height or width and an overflow mode such as auto or scroll. In practice, vertical scrolling is the common case.

html
1<div class="panel">
2  <h2>Release Notes</h2>
3  <p>Line 1</p>
4  <p>Line 2</p>
5  <p>Line 3</p>
6  <p>Line 4</p>
7  <p>Line 5</p>
8  <p>Line 6</p>
9  <p>Line 7</p>
10  <p>Line 8</p>
11</div>
css
1.panel {
2  height: 180px;
3  overflow-y: auto;
4  padding: 12px;
5  border: 1px solid #bbb;
6  -webkit-overflow-scrolling: touch;
7}

The key line for iOS is -webkit-overflow-scrolling: touch;. It enables momentum scrolling, which makes nested scroll areas feel native on touch devices.

Why the Scrollbar Seems Missing

On iOS, scroll indicators are typically transient. They appear while the user is actively scrolling and then fade out. That is normal platform behavior. CSS can make the element scrollable, but it cannot force iOS Safari to keep a classic scrollbar permanently painted.

So the right goal is usually:

  • make the container actually scroll
  • preserve smooth touch behavior
  • provide enough visual cues that the area is scrollable

A subtle fade or clipped content edge often works better than fighting the platform.

Patterns That Work Better Than Forcing a Scrollbar

A common pattern is to combine overflow with a fixed height and a visible boundary.

css
1.panel {
2  height: 180px;
3  overflow-y: auto;
4  border-radius: 10px;
5  border: 1px solid #d0d0d0;
6  background: linear-gradient(#ffffff, #fafafa);
7  -webkit-overflow-scrolling: touch;
8}
9
10.panel::after {
11  content: "";
12  display: block;
13  height: 12px;
14}

The extra spacing at the end prevents the last line from feeling glued to the bottom edge. You can also show a heading such as “Scroll for more” above the panel if discoverability matters.

If the whole page already scrolls, nested scrollers can feel awkward. In that case, consider letting the page handle scrolling instead of creating a second scroll region.

A Practical Markup Pattern

In real layouts, the scrollable area is often inside a card or modal. Make the outer shell responsible for spacing and borders, and let the inner element handle overflow.

html
1<section class="card">
2  <header>Activity</header>
3  <div class="card-scroll">
4    <p>Update 1</p>
5    <p>Update 2</p>
6    <p>Update 3</p>
7    <p>Update 4</p>
8    <p>Update 5</p>
9  </div>
10</section>
css
1.card-scroll {
2  max-height: 220px;
3  overflow-y: auto;
4  -webkit-overflow-scrolling: touch;
5}

That separation avoids bugs where padding, border radius, and overflow compete with each other.

Limits of Scrollbar Styling on iOS

Developers sometimes try ::-webkit-scrollbar to style the scrollbar. That works in several desktop WebKit contexts, but support is limited and inconsistent on iOS Safari. Even where some styling appears, it is not a reliable way to guarantee a persistent visible track.

That means the best portable solution is structural CSS, not custom scrollbar painting.

Common Pitfalls

The first pitfall is setting overflow: auto without a fixed height. If the element can expand to fit its content, there is nothing to scroll.

Another common issue is forgetting -webkit-overflow-scrolling: touch, which makes the container feel less natural on iOS.

A third mistake is trying to force desktop-style scrollbar behavior on a mobile browser that intentionally hides indicators most of the time. Build around the native behavior instead.

Summary

  • 'overflow-y: auto works on iOS when the element has a constrained size.'
  • '-webkit-overflow-scrolling: touch improves nested scrolling behavior.'
  • iOS usually shows scroll indicators only while the user is scrolling.
  • '::-webkit-scrollbar is not a dependable solution for always-visible iOS scrollbars.'
  • Design the container so its scrollability is obvious even when the indicator is hidden.

Related reading
Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

All Rights Reserved.