← Back to Bootstrap Course | Chapter 8: Components — Modals & Offcanvas | Lesson 3 of 8

Scrollable modal

A scrollable modal keeps its header and footer fixed while only the body scrolls.

In this page:

  1. Scrollable modal
Syntax
markup
<div class="modal-dialog modal-dialog-scrollable">
  <div class="modal-content">...</div>
</div>

Scrollable modal

Add .modal-dialog-scrollable to the dialog so long content scrolls inside the body. Without it, the whole modal scrolls with the page. Use it for terms of service and long forms.

Note: Combine modal-dialog-scrollable with modal-dialog-centered when appropriate.

Example: Scrollable modal

markup
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
  <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body class="p-3">
<div class="container">
  <button class="btn btn-outline-secondary" data-bs-toggle="modal" data-bs-target="#long">Scrollable modal</button>
  <div class="modal fade" id="long" tabindex="-1" aria-hidden="true">
    <div class="modal-dialog modal-dialog-scrollable">
      <div class="modal-content">
        <div class="modal-header"><h5 class="modal-title">Terms</h5></div>
        <div class="modal-body"><p>Very long text... </p><p style="height:600px">Tall content that scrolls inside the body.</p><p>The end.</p></div>
        <div class="modal-footer"><button class="btn btn-primary" data-bs-dismiss="modal">Accept</button></div>
      </div>
    </div>
  </div>
</div>
</body>
</html>
Live Example
Related Topics
Common Mistakes
  1. Forgetting the class so the page scrolls
  2. Very tall content without scroll
  3. Nested scroll areas
Chapter Summary
  • modal-dialog-scrollable
  • Header and footer stay fixed
  • Only the body scrolls
  • Good for long text
🔒

Chapter Quiz — Complete all 8 topics to unlock

0/8 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.